Skip to content

Ubuntu 17.04 / CakePHP / Grunt w/SASS / Foundation #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.DS_Store
.vagrant
.idea/
/cakephp/
/symfony-standard/
/wordpress/
/laravel-quickstart/
/create_ssl.sh
18 changes: 13 additions & 5 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Set up a PHP development box super fast
=======================================
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/dirkaholic/vagrant-php-dev-box?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dirkaholic/vagrant-php-dev-box?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Installation
------------
Expand All @@ -10,12 +11,14 @@ Installation
* Clone this repository and cd into it
* Run ```vagrant up``` in order to set up the box using the ```ansible_local``` provisioner
* You should now have your working
* Symfony2 Standard Edition under http://192.168.50.4:8081/
* Laravel Quickstart example app under http://192.168.50.4:8082/
* Symfony2 Standard Edition under https://192.168.50.4:8081/
* Laravel Quickstart example app under https://192.168.50.4:8082/
* CakePHP base installation under https://192.168.50.4:8083/
* Wordpress base installation under https://192.168.50.4:8084/

The installation process will create a folder symfony-standard inside
The installation process will create folders symfony-standard, laravel-quickstart, cakephp, wordpress inside
the main directory of the repository. You can now start working inside
this folder directly on your host computer using your favourite IDE.
these folders directly on your host computer using your favourite IDE.
Changes done there will be reflected directly on the vagrant box as the
directory is mounted in the vagrant box under ```/vagrant```. Also you
can login into the box using ```vagrant ssh``` and have the full control
Expand All @@ -26,6 +29,8 @@ repeat the whole procedure at any time. In order to start fresh just run
```vagrant destroy``` and ```vagrant up```. This will undo all you manual
changes done on the vagrant box and provide you with a clean setup.

NOTE: You must delete or move the development folders prior to ```vagrant up``` after a destroy. If these folders exist, the process will fail.

Installed components
--------------------

Expand All @@ -35,8 +40,11 @@ Installed components
* [php-fpm](http://php-fpm.org)
* [git](http://git-scm.com/)
* [Composer](https://getcomposer.org/)
* [CakePHP 3](https://cakephp.org)
* [Wordpress](https://wordpress.org)
* [Symfony2 Standard Edition](https://github.com/symfony/symfony-standard)
* [Laravel](https://laravel.com/)
* [NodeJS](https://nodejs.org)
* [PHPUnit](https://phpunit.de/)

If you don't like/need some of the components just remove them from the roles section in playbook/vagrant.yml.
Expand Down
8 changes: 7 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@ Vagrant.require_version ">= 1.7.0"
Vagrant.configure(2) do |config|

config.vm.box = "bento/ubuntu-16.04"
#config.vm.box = "xenji/ubuntu-17.04-server"
#config.vm.box = "wholebits/ubuntu17.04-64"

# Disable the new default behavior introduced in Vagrant 1.7, to
# ensure that all Vagrant machines will use the same SSH key pair.
# See https://github.com/mitchellh/vagrant/issues/5005
config.ssh.insert_key = false
config.ssh.keep_alive = true


# Run Ansible from the Vagrant VM
config.vm.provision "ansible_local" do |ansible|
ansible.verbose = "vv"
ansible.playbook = "playbooks/vagrant.yml"
ansible.install_mode = "pip"
ansible.version = "2.2.3.0"
end

config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "private_network", ip: "192.168.50.4"
end
end
9 changes: 8 additions & 1 deletion playbooks/roles/base/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
- name: Install required base packages
apt: name={{ item }} state=present

with_items:
- curl
- git
- python-mysqldb
- zip
- unzip
- unzip
- npm
- ruby

- name: Install NodeJS
shell: curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - && sudo apt-get install -y nodejs

6 changes: 6 additions & 0 deletions playbooks/roles/cakephp/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
dependencies:
- { role: base }
- { role: mysql }
- { role: php-fpm }
- { role: nginx }
147 changes: 147 additions & 0 deletions playbooks/roles/cakephp/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
---
- name: Create MySQL database for CakePHP
mysql_db: name=cakephp state=present

- name: Create MySQL user for CakePHP
mysql_user: name=cakephp password=cakephp priv=*.*:ALL state=present

- name: Install CakePHP
command: composer create-project --prefer-dist cakephp/app cakephp
args:
chdir: /vagrant
creates: /vagrant/cakephp
become: true
become_user: "{{ www_user }}"
ignore_errors: yes

- name: Remove default CakePHP app.php
file:
path=/vagrant/cakephp/config/app.php
state=absent

- name: Copy across new CakePHP app.php
template:
src=app.php.j2
dest=/vagrant/cakephp/config/app.php
become: true
become_user: "{{ www_user }}"

- name: Remove default CakePHP composer.json
file:
path=/vagrant/cakephp/composer.json
state=absent

- name: Copy across new composer.json
template:
src=composer.json.j2
dest=/vagrant/cakephp/composer.json
become: true
become_user: "{{ www_user }}"

- name: Composer Update (to install Foundation 6)
shell: cd /vagrant/cakephp && composer update
become: true
become_user: "{{ www_user }}"

- name: Copy across new php-fpm pool config for CakePHP
template:
src=php-fpm.conf.j2
dest=/etc/php/{{ php_version }}/fpm/pool.d/cakephp.conf
notify:
- restart php-fpm

- name: Copy across new virtual host for CakePHP
template:
src=nginx.conf.j2
dest=/etc/nginx/sites-available/cakephp.conf
notify:
- restart nginx

- name: Enable new vagrant virtual host for cakephp
file:
src=/etc/nginx/sites-available/cakephp.conf
dest=/etc/nginx/sites-enabled/cakephp.conf
state=link
notify:
- restart nginx

- name: Copy NPM package.json
template:
src=package.json.j2
dest=/vagrant/cakephp/package.json
become: true
become_user: "{{ www_user }}"

- name: NPM Install
shell: cd /vagrant/cakephp && sudo npm -g install grunt
become: true
become_user: "{{ www_user }}"

- name: NPM Install local project
shell: cd /vagrant/cakephp && npm --no-bin-links install
become: true
become_user: "{{ www_user }}"

- name: Install required GEM packages
apt: name={{ item }} state=present
with_items:
- ruby-sass

- name: Install GEM
shell: cd /vagrant/cakephp && sudo apt-get -y install ruby-sass

- name: Install GEM
shell: cd /vagrant/cakephp && sudo gem install sass

- name: Copy gruntfile.js
template:
src=gruntfile.js.j2
dest=/vagrant/cakephp/gruntfile.js
become: true
become_user: "{{ www_user }}"

- name: Make sass directories
shell: mkdir /vagrant/cakephp/webroot/scss
become: true
become_user: "{{ www_user }}"
ignore_errors: yes

- name: Copy default layout with new sass
template:
src=default.ctp.j2
dest=/vagrant/cakephp/src/Template/Layout/default.ctp
become: true
become_user: "{{ www_user }}"
ignore_errors: yes

- name: Copy default layout with new sass
template:
src=main.scss.j2
dest=/vagrant/cakephp/webroot/scss/main.scss
become: true
become_user: "{{ www_user }}"
ignore_errors: yes

- name: Copy js with new custom js
template:
src=custom.js.j2
dest=/vagrant/cakephp/webroot/js/custom.js
become: true
become_user: "{{ www_user }}"
ignore_errors: yes

- name: Copy over rc.local file
template:
src=rc.local.j2
dest=/etc/rc.local
ignore_errors: yes

- name: setup GRUNT on boot
shell: sudo systemctl enable rc-local.service

- name: Copy Foundation Icons
shell: cp -fr /vagrant/cakephp/node_modules/foundation-icons /vagrant/cakephp/webroot/font/foundation-icons
become: true
become_user: "{{ www_user }}"
ignore_errors: yes

24 changes: 24 additions & 0 deletions playbooks/roles/cakephp/templates/.env.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
APP_ENV=local
APP_DEBUG=true
APP_KEY=a0888cfd6538f2ded11ed14b163eee30f732c5b8
APP_URL=http://192.168.50.4:8083/

DB_HOST=127.0.0.1
DB_DATABASE=cakephp
DB_USERNAME=cakephp
DB_PASSWORD=cakephp

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
Loading