Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Solomon Scott
Solomon Scott
20,586 Points

Laravel - How to set up a different project

I'm trying to set up a different project besides the one I did for the tutorial. When I try to use the Homestead.yaml to change where the laravel.dev localhost points, I sill get the old project. I'm not sure if there is anything else I have to change?

3 Answers

geoffrey
geoffrey
28,736 Points

I'm still following the tutorial and thus haven't tried to create another project yet. But I think the matter is to change information in the host file.

For exemple I'm on linux, the host file is located at /etc/hosts If I open that file I have this and some others information I deleted:

127.0.0.1 laravel.dev /* Which is what I set for the tutorial.

127.0.0.1 newProject.dev /* Which is what I would add for another project*/

127.0.0.1 localhost

127.0.1.1 Geo-On-The-Web

This way, now I could access it by typing newProject.dev:8000, such as we do in the tutorial.

Solomon Scott
Solomon Scott
20,586 Points

I just did that and everything work perfectly. Thanks!

Just in case you swapped out the entire site: section for a new project, you can add multiple sites to homestead.yaml

sites:
    - map: laravel-basics.dev
      to: /home/vagrant/Sites/laravel-basics/public   
    - map: another-project.dev
      to: /home/vagrant/Sites/another-project/public
    - map: yet-another-project.dev
      to: /home/vagrant/Sites/yet-another-project/public

After you've made your changes in Homestead.yaml, run

vagrant provision
Aj Villalobos
Aj Villalobos
1,864 Points

Did you generate a new laravel project for that? I'm not sure you could do that.

composer create-project laravel/laravel [project]

geoffrey
geoffrey
28,736 Points

What does exactly the vagrant provision command do ? It takes into considerations the changements done in the Homestead Yaml file ? I've checked the vagrant documentation https://docs.vagrantup.com/v2/cli/provision.html but it doesn't talk a lot to me...

Solomon Scott
Solomon Scott
20,586 Points

From what I read, that is exactly what it does.