Develop Laravel applications using the PHPStorm editor

(*-*)浩
Release: 2019-11-27 18:20:16
Original
4111 people have browsed it

Develop Laravel applications using the PHPStorm editor

I believe there are many PHP programmers using [laravel] to create their applications. [laravel] is a free and open source PHP web application framework. It is based on multiple Symfony components and provides a development framework, including authentication, routing, sessions, caching and other modules. (Recommended learning: phpstorm detailed explanation)

Last summer, we introduced support for Blade. Blade is Laravel's template language, artist-friendly, and a command-line tool for Laravel programmers that can work in PhpStorm. Using Laravel plugins and Laravel IDE helpers, we can further extend PhpStorm's support for Laravel applications. Let's see how to do it!

Install Laravel IDE Assistant

##Official way

First make sure Composer is in It is available in our project, we can use Composer | Add dependency… right-click menu to install [Laravel 5 IDE Helper Generator] to our project. Search barryvdh/laravel-ide-helper, and click Install to download and add to the project.

Self-service method

Because we are using it in the project, we add this function to the project and add the require-dev branch in composer.json

laravel 4.*, the version here should be filled in 1.*

"require-dev": {
  // ...
  "barryvdh/laravel-ide-helper": "2.*"
  // ...
},
Copy after login

Then use the command composer update -vvv to update the package

Register 'Barryvdh\LaravelIdeHelper \IdeHelperServiceProvider' service to our application.

is written to the provider in config/app.php, so that the ide-helper command exists in the artisan list. Run artisan ide-helper:generate, and PhpStorm will have the code completion function. And it has Laravel’s syntax highlighting.

Laravel plug-in in PhpStorm

In order to further enhance our Laravel experience, we can also install the Laravel plug-in. In Settings (Preferences) | Plugins, click Browse repositories… button and search for Laravel. The Install plugin button will download and install the plugin to the IDE.

Develop Laravel applications using the PHPStorm editor

Restart the IDE and enable the plugin (Settings (Preferences) | Other Settings | Laravel Plugin | Enable Plugin for this Project). PhpStorm knows what Laravel's interface does, and provides code completion functions for (controllers, views, routes, configuration, translations, etc.)!

Of course it's not just code completion, use Ctrl Click (CMD Click Mac OS X) or Go To Declaration (Ctrl B / CMD B), PhpStorm will navigate there, such as the declaration of the configuration item.


Regarding using Blade templates, Laravel plug-ins can also improve the experience, such as: automatic completion of @section instructions.


Want to know more? Check out our Laravel Tutorial, which covers everything PhpStorm has to offer for Laravel development, including code auto-completion, navigation, automatic code inspection, command line tool support, debugging and unit testing!

You can also add commands to the post-update-cmd of composer.json to ensure that the helper will be updated every time it is updated, as follows:

"post-update-cmd": [
  "php artisan clear-compiled",
  "php artisan ide-helper:generate",
  "php artisan optimize"
 ],
Copy after login

In addition, if your model is extend Eloquent, this plug-in can also add phpDoc to the model in the project and directly display the field names for easy reading. Usage

php artisan ide-helper:models User
Copy after login

needs to modify composer.json and add

"require-dev": {  
  "doctrine/dbal": "~2.3"
},
Copy after login
in the require-dev section.

The above is the detailed content of Develop Laravel applications using the PHPStorm editor. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!