Creating a new Laravel Project with Homestead

Viewed 224

I'm trying to create a Laravel project. I currently have Homestead up and running. There is no git repository yet nor is there a local directory. Only homestead as of now.

Let's say I'm trying to create a laravel project called laravel-vue, how would I go about mapping it and where would I type the "composer create-project laravel/laravel my-laravel-project" command?

I'm thinking Homestead.yaml might look something like this:

folders:
- map: D:\laravel-vue
  to: /home/vagrant/laravel-vue

sites:
- map: homestead.test
  to: /home/vagrant/laravel-vue/public

I do not have php installed on this machine so I'll have to use Homestead to have access to the composer.

Should I manually create a folder in D:? should I create the Laravel project after using vagrant ssh? What is /public?

1 Answers

Since you have Homestead up and running the next steps would be as follows. Try to fix your Homestead.yaml inside your Homestead folder. For example:

---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Code
to: /home/vagrant/Code
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
- map: mylaravelapp.dev
to: /home/vagrant/Code/mylaravelapp/public
databases:
- homestead
- mylaravelapp

Once you have done that, continue with booting the virtual machine. Cd into the Homestead folder and execute the following command :

vagrant reload --provision

The virtual machine will start booting and configuring. Then execute

vagrant ssh
cd Code
composer create-project laravel/laravel mylaravelapp

These 3 commands will ssh into the machine, go to the shared Code folder and create a new Laravel project with Composer. This will clone the Laravel repository and will begin installing Composer dependencies. This will install the latest Laravel version. Once the installation finishes go to C:\Windows\System32\drivers\etc\hosts and add the following: 192.168.10.10 mylaravelapp.dev

Open your browser and go to http://mylaravelapp.dev

Related