Examples of phpstorm development laravel application

Source: Internet
Author: User
Tags laravel tutorial
This article mainly introduces the use of Phpstorm how to develop laravel application of the relevant information, the text through the sample code introduced in very detailed, to everyone's study or work has a certain reference learning value, the need for friends under the small to learn to learn under the next.

Objective

It is believed that many PHP programmers use [laravel] to create their applications. [Laravel] is a free, 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.

Last summer, we introduced support for Blade. Blade is Laravel's template language, which is friendly to artists, and this laravel Programmer's command-line tool can work in Phpstorm. With the Laravel plug-in and the Laravel IDE helper, we can further extend Phpstorm support for Laravel apps. Let's see what we can do!

Installing the Laravel IDE Assistant

Official Way

First confirm that Composer is available in our project and we can use Composer | Add dependency ... Right-click menu to install [Laravel 5 IDE Helper Generator] to our project. Search for Barryvdh/laravel-ide-helper, and click Install to download and add to the project.

Self-help Way

Because we are using it in the project, we add this feature to the project and add the Require-dev branch to the Composer.json
Laravel 4.*, the version here should be filled in 1.*


"Require-dev": {  //...  " Barryvdh/laravel-ide-helper ":" 2.* "  //...},

Then use the command composer UPDATE-VVV to update the package

Register the ' Barryvdh\laravelidehelper\idehelperserviceprovider ' service to our app, which is written to the provider in config/app.php so that it is stored in the artisan list In the Ide-helper command, run artisan ide-helper:generate, Phpstorm will have code completion function, and have laravel syntax highlighting.

Laravel plugins in the Phpstorm

To further enhance our laravel experience, we can also install the Laravel plugin. In Settings (Preferences) | Plugins, click Browse repositories ... button and search for Laravel. The Install Plugin button downloads and installs the plugin to the IDE.

Restart the IDE and enable plugins (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, etc.)!

Of course not only is the code auto-complete, using Ctrl+click (Cmd+click Mac OS X) or go to Declaration (goto definition) (ctrl+b/cmd+b), Phpstorm will navigate there, such as the declaration of the configuration item.

With the Blade template, the Laravel plugin can also improve the experience, such as: automatic completion of @section instructions.

Want to know more? Check out our Laravel tutorial, which contains everything phpstorm prepared for Laravel development, including code completion, navigation, automatic code checking, command line tool support, debugging, and unit testing!

You can also add a command to the Composer.json Post-update-cmd to ensure that the helper is updated every time the update occurs, as follows:


"Post-update-cmd": [  "PHP artisan clear-compiled",  "PHP artisan ide-helper:generate",  "PHP artisan Optimize "],

In addition, if your model is extend eloquent, this plugin can also add Phpdoc to the model in the project, directly display the field name, easy to read, use


PHP Artisan ide-helper:models User

Need to modify Composer.json, add in Require-dev segment


"Require-dev": {    "Doctrine/dbal": "~2.3"},

Summarize

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.