How to Develop Laravel applications using PHPStorm: phpstormlaravel
Preface
I believe many PHP programmers use [laravel] to create their applications. [Laravel] is a free and open-source PHP web application framework. Based on Multiple Symfony components, it provides a development framework, including authentication, routing, sessions, caching, and other modules.
Last summer, we introduced support for Blade. Blade is Laravel's template language and is artist-friendly. This Laravel programmer's command line tool can work in PhpStorm. with the Laravel plug-in and Laravel IDE help, we can further extend PhpStorm's support for Laravel applications. Let's see how it works!
Install Laravel IDE Assistant
Official Mode
First, make sure that Composer is available in our project. We can use Composer | Add dependency... Right-click the menu to Install [Laravel 5 IDE Helper Generator] to our project. Search for barryvdh/laravel-ide-helper, and click Install to download and add it to the project.
Self-help
Because it is used in the project, we add this function in the project and add the require-dev branch in composer. json.
Laravel 4. *, the version here should be set to 1 .*
"require-dev": { // ... "barryvdh/laravel-ide-helper": "2.*" // ...},
Run composer update-vvv to update the package.
Register the 'barryvdh \ LaravelIdeHelper \ idehelperserviceprovider' service to our application, which is written to config/app. in php, the ide-helper command exists in artisan list. Run artisan ide-helper: generate and PhpStorm to complete the code, laravel syntax is highlighted.
Laravel plug-in PhpStorm
To further improve the Laravel experience, we can also install the Laravel plugin. In Settings (Preferences) | Plugins, Click Browse repositories... Click and search for Laravel. Install plugin to download and Install the plug-in to the IDE.
Restart the IDE and Enable the plug-in (Settings (Preferences) | Other Settings | Laravel Plugin | Enable Plugin for this Project ). phpStorm knows what the Laravel interface does and provides Code Completion functions (controllers, views, routes, configuration, translations, and so on!
Of course, it's not just code automation. use Ctrl + Click (CMD + Click Mac OS x) or Go To Declaration (To definition) (Ctrl + B/CMD + B ), phpStorm will navigate to it, such as the declaration of configuration items.
The Laravel plug-in can also improve the user experience by using the Blade template. For example, the @ section command is automatically completed.
Want to know more? View our Laravel tutorial. It contains all the things PhpStorm has prepared for Laravel development, including code autocompletion, navigation, automatic code check, command line tool support, debugging, and unit testing!
You can also add commands in composer. json's post-update-cmd to ensure that helper will be updated each time it is updated, as shown below:
"post-update-cmd": [ "php artisan clear-compiled", "php artisan ide-helper:generate", "php artisan optimize" ],
In addition, if your model is extend's Eloquent, this plug-in can also add phpDoc to the model in the project to directly display the field name, which is easy to read and use.
php artisan ide-helper:models User
You need to modify composer. json and add it in the require-dev section.
"require-dev": { "doctrine/dbal": "~2.3"},
Summary
The above is all the content of this article. I hope the content of this article will help you in your study or work. If you have any questions, please leave a message, thank you for your support.
References:
Use PHPStorm to develop Laravel applications
Laravel Development using PhpStorm