Posts Learn Components Snippets Categories Tags About
/

Make PhpStorm Smarter for Laravel Development

Learn how to make PhpStorm smarter for Laravel development by allowing for accurate autocompletion and more with Laravel IDE helper

Created on Aug 04, 2021

24 views

To make PhpStorm smarter and provide accurate autocompletion for Laravel development, you can install the Laravel IDE Helper Generator package by Barry vd. Heuvel.

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"
    ]
}

Snippets by

PostSrc poster

PostSrc

Full stack developer mainly focusing on the front end side of the web. The main author of PostSrc and loves writing tutorial and guides online.

Load comments for Make PhpStorm Smarter for Laravel Development

new

PostSrc Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that's right for your project.

View Components

Other Code Snippets

More