This package will help to generate all the necessary files, metadata, and docblocks that will allow PhpStorm to know more about the classes, methods, and properties.
Step 1 - Install Laravel IDE Helper
Require the package using composer.
composer require --dev barryvdh/laravel-ide-helper
Step 2 - Run Command to Generate PHPDoc
Once it's installed, you can run the command to generate the PHPDoc.
php artisan ide-helper:generate php artisan ide-helper:models -W php artisan ide-helper:meta
Step 3 - Invalidate Caches / Restart PhpStorm
The final step is to invalidate existing caches or restart your PhpStorm to let it re-index all of the files.
Optional: Publish Configuration
To publish configuration you can run the command below.
php artisan vendor:publish --provider="Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider" --tag=config
Optional: Composer Post Update Command
Sometimes you don't want to type out the command to re-generate the PHPDoc, to automatically do that after "composer update" you add the following "post-update-cmd" which will run after updating dependencies.
# composer.json "scripts": { "post-update-cmd": [ "Illuminate\\Foundation\\ComposerScripts::postUpdate", "@php artisan ide-helper:generate", "@php artisan ide-helper:models -W", "@php artisan ide-helper:meta" ] }
Leave a reply