码迷,mamicode.com
首页 > Web开发 > 详细

Laravel 4 Development on PHPStorm

时间:2014-07-29 12:42:06      阅读:309      评论:0      收藏:0      [点我收藏+]

标签:des   http   color   os   io   for   art   cti   

Laravel & PHPStorm – the best of the two worlds. Laravel is the most popular PHP web framework today. PHPStorm is the best PHP IDE that money can buy. What’s sad is that 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 has received quite a good number of votes by today. I do hope Laravel support will come soon on the IDE. Meanwhile, there are 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 autocompletion for Laravel by default. But there are 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 is 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 be installed if everything goes right. Now, you need to make sure the package is loaded in Laravel (so that 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 you can do this in 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 restarts, you should get code completion for most of the Laravel code.

Blade Syntax

This one could be a bit tricky. But if you have 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 the color schemes to Darcula. (In my case, I switched all to Dracula under the “TextMate Color Scheme” column. If you click an item under that column, you should get a pop up to select.)

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

Laravel 4 Development on PHPStorm,布布扣,bubuko.com

Laravel 4 Development on PHPStorm

标签:des   http   color   os   io   for   art   cti   

原文地址:http://www.cnblogs.com/gardenliu/p/3874827.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!