I am quite buzzed with the whole Homestead stuff and how it correlates with an IDE. Let's say I have my PhpStorm installed in ~/Developer/PhpStorm
The Homestead is in ~/Developer/Homestead
. This is how my YAML file in Homestead looks like:
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Developer/Homestead/workspace
to: /home/vagrant/Code
sites:
- map: helloworld.app
to: /home/vagrant/Code/Laravel/public
variables:
- key: APP_ENV
value: local
So, you see that I have a workspace folder in the Homestead directory.
I also have another directory: ~/Developer/workspace/PHP
where I am planning to store my projects, instead of in the Homestead folder.
I installed the Laravel plugin in PhpStorm. And, in order for the Laravel plugin to work in PhpStorm, this generated file is needed. My questions are:
_ide_helper.php
file so that PhpStorm works properly with Laravel? Should I paste it in each project or just once somewhere?You shouldn't need to put the _ide_helper.php
file anywhere manually, it is automatically generated by the Artisan command. For each new project, include the IDE helper in that project's composer.json
file:
"require-dev": {
"barryvdh/laravel-ide-helper": "1.*"
}
Add the service provider to the providers array in the config.php
file of your Laravel project:
'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider'
Then use Artisan to generate the _ide_helper.php
file for the project (run this command from the terminal in the root of your Laravel project directory):
php artisan ide-helper:generate
This is all paraphrased from the instructions on the IDE Helper GitHub page. I would recommend following those instructions to also set up your composer.json file to auto-generate a new _ide_helper.php
whenever composer updates.
Yes. For each individual Laravel project, you'll need to update your sites mapping in the YAML file. For my projects, I use this scheme (note that you are mapping to the location relative to your Vagrant box):
sites:
- map: local.project.example.com
to: /home/vagrant/Projects/project/public
Then in your Homestead directory, run:
vagrant provision
You will also need to update your hosts file to point to the Vagrant box.
sudo nano /etc/hosts
Add the line:
127.0.0.1 local.project.example.com
Now you should be able to access this Laravel project by hitting: local.project.example.com:8000
in your web browser.
Assuming you followed the Laravel installation instructions, the easiest way is to use the Laravel command in the terminal. To create a new Laravel project called "blog", navigate to ~/Developer/workspace/PHP
and run the command:
laravel new blog
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With