5

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:

  1. Where exactly should I put the _ide_helper.php file so that PhpStorm works properly with Laravel? Should I paste it in each project or just once somewhere?
  2. Do I have to write a different app name in the YAML sites: map field for every project that I want to be launching atm?
  3. How do I create a new Laravel type project. As when I go for creating a new project in PhpStorm, there are types of which I can choose - should I also have Laravel listed there, because I do not? Because now, when I create a new PHP project - it's completely empty. And I suppose a Laravel project should have some architecture and generated files.
  4. I beg of a simple explanation of all this Laravel + Homestead stuff and Vagrant and how to control my projects, because I am getting very frustrated and I have to start working with these technologies on my Bachelor project soon.
3
  • I can recommend you to use Laravel plugin for PhpStorm instead of helper: much easier and it's creator constantly improving the plugin. plugins.jetbrains.com/plugin/7532?pr=phpStorm Commented Nov 20, 2014 at 14:02
  • @Kootli - that is what I have installed already. But still the helper is needed. It is even mentioned in the plugin's installation guide. :) Commented Nov 20, 2014 at 14:36
  • About your first question: Just copy the helper file to your project root and synchronize Commented Nov 20, 2014 at 14:43

2 Answers 2

5
  1. 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.


  1. 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.


  1. 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
    

  1. I hope the above answers get you started down the right path. The most important thing is to carefully read the Laravel documentation as it covers everything I just did but in much greater detail.
Sign up to request clarification or add additional context in comments.

Comments

0

thanks Mike Andersen, you have put me on correct way, but your solution number 1 don't work for me (using Laravel 5).

You have to run "composer update" after making changes to composer.json file. But, when i have doed, i got this error:

barryvdh/laravel-ide-helper v1.2.1 requires phpdocumentor/reflection-docblock dev-master#6d705c1a0f9e2a6d73d2e9ec0e538b9dfaf4315f -> no matching package found.

I have got another solution:

  1. remove line about "barryvdh/laravel-ide-helper" from require array on composer.json file.
  2. run the next line: composer require barryvdh/laravel-ide-helper

Then you can follow the steps proposed by Mike Andersen:

  1. Add the service provider to the providers array in the config.php file of your Laravel project:

    Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider

  2. 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

  3. Open your project on phpStorm and go to: File|Synchronize.

And you will got your laravel project updated with the last version of barryvdh/laravel-ide-helper extension

(More info: https://github.com/barryvdh/laravel-ide-helper)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.