Add a project to local development environment

developmentI’ve decided to add an addendum to the last 2 posts (part 1 and part 2) on how to setup a local development environment, namely how to add a new project.

It’s easy an I’m sure you would have figured it out on your own with the information already given, but I like the site to be complete and who doesn’t like a good walkthrough!

Let’s add a project surprisingly called ‘project2’.

My projectcode is on GitHub. Clone the new project in our ‘Code’ directory. From the terminal:

$ git clone ~/Code/project2

Add it to our homestead config:

$ cd ~/Homestead
$ vagrant halt
$ vi Homestead.yaml

Add your new project:

ip: ""
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/

- ~/.ssh/id_rsa

- map: ~/Code
to: /home/vagrant/code

- map: projectname.test
to: /home/vagrant/code/projectname/public
php: "7.2"
- map: project2.test
to: /home/vagrant/code/project2/public
php: "5.6"

- homestead

As you can see, it’s a piece of cake to specify and use next to each other different PHP versions for different projects.

Get your new config active and SSH into your box:

$ vagrant up --provision
$ vagrant ssh

Add a new database via Sequel Pro to your homestead box in the dev_project2 fashion. Import your test or acc database to it when your have this, or else create a new database from scratch. When URLs are hard coded in the database, change them to your local URL like http://project2.test.

Finally, don’t forget to add these database credentials to the file you normally use to store these, such as .env, db.php, wp-config.php, etc.

Add your site to your hosts file, via terminal, Gas Mask, or whatever: project2.test

You can now browse to http://project2.test.

Often the project needs some extra config or modules, as discussed before. From your homestead box:

$ cd /home/vagrant/code/project2
$ composer install

It varies per project what you’ll need, but you’ll now of course. Just don’t forget it.

So its this easy to add another project to your local development environment.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.