This is specifically designed to give you a fully working ZF2 Skeleton Application in a vagrant environment. I have gone through and painstakingly put together a setup that once cloned will require X steps to completely have a working LAMP stack in a virtual machine. If you are looking for a guide on how to work with ZendFramekwork, VirtualBox, or Vagrant go to their website's and RTM.
- Clone ZF2VagrantBase
https://github.com/gwagner/ZF2VagrantBase.git
- Install Vagrant
http://downloads.vagrantup.com/
- Install VirtualBox
https://www.virtualbox.org/wiki/Downloads
- Inside of your clone of ZF2VagrantBase, navigate to the vagrant directory
- Type
vagrant up
- Once the machine is up and running, navigate to http://192.168.1.12
- Profit!!!
Note: On your first
vagrant up
you will download a ~400MB CentOS image. This will take some time. Every subsequent run ofvagrant up
will not re-download the image.
Since the version bump to 1.1+ for Vagrant, there is a divergence from previous configuration files to the new configuration files. I have supplied a Vagrantfile_1 and a Vagrantfile_2 for use with this project. By default the contents of Vagrantfile are a direct copy of the contents from Vagrantfile_2. I have commented the proper configuration changes that need to be made in the Vagrantfile_1 if you are using Vagrant < 1.1.
Note: The version change has made things a little confusing. Try and default to using the default setup with Vagrant 1.1+ If that is not an option and you can not get things working on your computer, feel free to contact @gwagner85 on twitter.
There is also a configuration file located in the /vagrant/modules folder named Puppetfile. This file holds the configuration file to determine what puppet modules need to be downloaded to install your fully working LAMP stack with ZF2.
Testing is pretty simple. Follow these steps if you plan on developing in the application module. If you are going creating your own module from scratch, use the application module as a template.
- Run tests without code coverage
- In your terminal, navigate to your vagrant directory
- Run the following command
vagrant ssh -c "sudo php /var/www/zf2/vendor/phpunit/phpunit/phpunit.php -c /var/www/zf2/test/phpunit-fast.xml"
- Run tests with code coverage
- In your terminal, navigate to your vagrant directory
- Run the following command
vagrant ssh -c "sudo php /var/www/zf2/vendor/phpunit/phpunit/phpunit.php -c /var/www/zf2/test/phpunit.xml"
Your testing log files will end up in PROJECT_ROOT/data/log
You can take the vagrant directory right out of this project directly into your project and use it. Once it is on your project (and you have installed VirtualBox / Vagrant), navigate to your vagrant directory and run vagrant up
from your terminal. It is very VERY portable that way. That will give you a VM running on YOUR existing project 👍
Note: You may need to disable the composer module from the zf2 module if you are not using composer in your project
These contributors are in no particular order