A Symfony 2 project running under a puphpet controlled virtual machine using Vagrant. We're going to be able to edit the project and run all the commands via PhpStorm.
Technically you probably don't need the Ubuntu bit ... but there are some specific gotchas in here. I've included the version numbers I've used in parentheses where applicable.
- Install Vagrant (1.4.2
- Install Virtual Box (4.3)
- Use PuPHPet to create your manifest file.
- Create 2 virtual hosts. One just for flat files to make sure editing our host works fine, and one for Symfony. I call them flathtml.vagrant and symfony.vagrant, so I know what they're referring to.
- The document root for these is /var/www/flathtml/ and /var/www/symfony/ respectively.
- These map to the folders /var/www/vagrant/flathtml/ and /var/www/vagrant/symfony/ respectively.
- At least, they will if I run Vagrant from /var/www/vagrant/.
- The mapping is taken care of automatically in the PuPHPet manifest, in the "Box Sync" section.
- Download those files to wherever it is you want the virtual server to be. I chose /var/www/vagrant/
- In the Vagrantfile, fine the line that starts with "config.vm.synced_folder" and add ":mount_options => ["dmode=777,fmode=777"]" to the end. Otherwise Symfony will not run.
- Using terminal, in /var/www/vagrant/, run "Vagrant Up"
- That should work after a while.
- Edit your hosts file "sudo gedit /etc/hosts/" and add your two virtual hosts to the file.
- The ip address is your Local VM IP Address. Most likely you left it as 192.168.56.101
- Get a test site with flat html working within Vagrant. This ensures that your Virtual server works.
- I ran into a problem here once of not being able to get the flat html site working, because the IP address I was being assigned came from DHCP, or similar. The trick is to change the Vagrantfile networking section. I can't remember the exact details of that fix sorry.
- Once that is working, then we can start with Symfony
- In Terminal, type "cd /var/www/vagrant/symfony"
- Install composer by "curl -s https://getcomposer.org/installer | php"
- Personally, I like to install it in a central location, such as /var/www/includes/.
- Now install Symfony by "php composer.phar create-project symfony/framework-standard-edition /var/www/vagrant/symfony/ 2.4.*"
- You may have to apt-get install php5-json as well.
- Now we can initialise the project in PhpStorm. We couldn't earlier as the create-project command will fail if anything is in the folder.
- Set up all your version control stuff now.
- I found this guy has some very good tips on setting up as well. In particular, steps 3-8.
- In app_dev.php and config.php, remove the lines that stop people on none localhost accessing. This will allow you to get to the configurator and make sure everything is working.
There are a lot more things you should be doing, but this is enough to get you up and running at least. I hope this helps someone.
No comments:
Post a Comment