The Gallery 3 development environment can easily be set up using Vagrant. Vagrant will download a prebuilt virtual development box configured so you can start hacking almost instantly.
These instructions have been tested on Linux, but the basic process is the same for both Windows and Mac.
Please install the following software:
Recommended versions are in parentheses. That's it! You don't need to have PHP, Apache or MySQL installed on your computer.
Fork the repository on GitHub and clone it:
$ git clone git://github.com/gallery/gallery3.git $ cd gallery3
Don't forget to replace gallery with your own GitHub username.
Vagrant needs to know where to find the Gallery development box. It finds this out by reading a file called `Vagrantfile` in the project root directory. You can obtain this file from here. Executing this command after cloning the repository in the previous step will make sure you have it in the right place:
$ wget https://raw.github.com/jozefs/gallery3-cookbook/master/dist/Vagrantfile
The developer box is currently hosted on Google Drive from where Vagrant cannot directly download. So you'll need to download (~550MB) the box manually and import it into Vagrant:
$ vagrant box add gallery3dev /path/to/downloaded.box
Add the following entry to your hosts file.
192.168.33.30 gallery3.local
On Linux, you can use this to add the entry:
$ sudo sh -c 'echo "192.168.33.30\tgallery3.local" >> /etc/hosts'
Everything is ready now for starting the development server! Simply 'up' the box:
$ vagrant up
After Vagrant downloads the box and boots it, you can proceed to your Gallery on the following URL:
http://gallery3.local
When you want to take a break from coding, use the following command to stop the box:
$ vagrant halt
Don't worry, if you forget to do this, the box will automatically be shut down when you shut down or restart your computer.
If you haven't used Vagrant before, we recommend reading their Getting Started guide to get a better understanding of how it works.
By default, it's configured to use a maximum of 1GB RAM.
To execute commands on the development box, e.g. to run unit tests, you need to log via ssh. In the root of the Gallery source directory, do this:
$ vagrant ssh
You're now logged into the VM. The source code is mounted in /gallery3:
$ cd /gallery3 $ ls
You should now see the Gallery source code. When you're done, you can get back to your host machine:
$ exit
MySQL is set up to allow remote connections for the root user. This is to make connecting to the database simpler to developers, and is not suitable for a production environment!
From the host machine:
$ mysql -h gallery3.local -u root -p gallery3
Within the VM:
$ vagrant ssh $ mysql -h localhost -u root -p gallery3
In both cases there is no password set.
Run the unit tests from within the development box:
$ vagrant ssh $ cd /gallery3 $ php index.php test
If for any reason you'd like to make a fresh start where the development environment is reset and Gallery uninstalled, follow these steps:
$ vagrant destroy $ rm -rf var $ vagrant up
Now you'll need to proceed to installing Gallery again:
http://gallery3.local