Laravel 4 Development on Phpstorm

Source: Internet
Author: User

Laravel & Phpstorm–the Best of the and the worlds. Laravel is the most popular PHP web framework today. Phpstorm is the best PHP IDE, so money can buy. What's sad is this there is still no built in support for Laravel in Phpstorm. I created an issue on youtrack (Jetbrain ' s issue tracker) a long time ago which have received quite a good number of votes by today. I do hope Laravel support would come soon on the IDE. Meanwhile, there is workarounds to get things done smoothly.

Auto completion

Thanks to the massive class aliasing (& use of facade) in the framework core, Phpstorm can ' t provide true Autocompleti On for Laravel by default. But there is excellent packages Likelaravel IDE Helperwhich can generate Phpdocs from the framework source. It generates a file which the IDE can parse and use the generated codes to provide autocompletion.

Installation and usage are simple. First modify your Composer.json to include it in the Require section:

{//[snip] "require": {"laravel/framework": "4.1.*", "Barryvdh/laravel-ide-helper": "Dev-master"}//[snip]}
{//[snip]

"Require": {

"Laravel/framework": "4.1.*",

"Barryvdh/laravel-ide-helper": "Dev-master"

}//[snip]}

Run Composer Update:

Composer Update
Composerupdate

The package should is installed if everything goes right. Now, your need to make sure the package is loaded in Laravel (so, artisan can execute the commands it provides). Add this to the providers array under app/config.php– ' Barryvdh/laravelidehelper/idehelperserviceprovider '. It should look like:

' providers ' = = Array (//[snip] ' illuminate/workbench/workbenchserviceprovider ', ' barryvdh/laravelidehelper/ Idehelperserviceprovider ',),

' Providers ' =>array (

[Snip]

' Illuminate/workbench/workbenchserviceprovider ',

' Barryvdh/laravelidehelper/idehelperserviceprovider ',

),

Now, can do this command line:

PHP Artisan Ide-helper:generate

Phpartisanide-helper:generate

The command should generate a file named "_ide_helper.php" with the necessary codes. You might want to recreate the code cache from "File" > "Invalidate caches/restart". When the IDE is restarts, you should get code completion for most of the Laravel code.

Blade Syntax

This one could is a bit tricky. But if you had installed textmate bundles into jetbrains IDEs, it ' s actually simpler.

(1) Download the textmate bundle Here–https://github.com/outofcontrol/blade.tmbundle. If you download the zip, uncompress it to somewhere on your harddisk.

(2) from Phpstorm ' s Settings window, go to TextMate Bundles. ADD the bundle and apply the changes.

(3) Go to "File Types" settings. Select "File types supported via TextMate bundles". Add "*.blade.php" to that list. Apply the changes. Now try and open a blade file. It should work.

(4) Additionally, if there ' s horrible color scheme on blade files, go back to "Settings" > "TextMate Bundles", assign T He color schemes to darcula. (In my case, I switched all to Dracula under the "TextMate Color Scheme" column. IF you click an item under this column, you should get a pops up to select.)

Now the blade syntax should work fine with nice color scheme.

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.