Laravel 4 Development on PHPStorm

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

时间: 2024-11-23 07:41:00

Laravel 4 Development on PHPStorm的相关文章

如何在 PhpStorm 使用 Code Generation?

實務上開發專案時,有一些程式碼會不斷的出現,這時可靠 PhpStorm 的 Code Generation 幫我們產生這些 code snippet,除此之外,我們也可以將自己的 code snippet 加入 Live Template,可加快發開速度,並減少 typo. Version PHP 7.0.8Laravel 5.2.41PhpStorm 2016.2 Namespace Laravel 5 的 app 目錄下都遵循 PSR-4,也就是每個在 app 目錄下的 class 都要有

awesome-php中英文资源整理(同步更新)

中文版 收集整理一些常用的PHP类库, 资源以及技巧. 以便在工作中迅速的查找所需… 这个列表中的内容有来自 awesome-php 的翻译, 有来自开发者周刊以及个人的积累等. 一个前端组件的列表 awesome-frontend 推荐 学习资源 PHP相关的有参考价值的社区,博客,网站,文章,书籍,视频等资源 PHP网站(PHP Websites) PHP The Right Way – 一个PHP实践的快速参考指导 PHP Best Practices – 一个PHP最佳实践 PHP We

PhpStorm下Laravel代码智能提示

phpstorm&Laravel PHPstorm是我见过的最好的PHP的IDE,前年用的时候就毫不犹豫的抛弃了zend studio :) ,Laravel是我用过最好的框架,除了做手游后台这类有高并发需求的项目的时候会使用swoole,像yii,thinkPHP,zend之类已经直接不在项目中用了,不过悲伤的是最好的IDE不支持最好的Laravel的代码提示,后来我在github上翻,找到了laravel4-phpstorm-helper这个工具,不过很遗憾,已经不更新很久了,后来在外国论坛

phpstorm laravel单元测试 配置

laravel中集成了单元测试工具phpunit可以在项目的根目录下进行使用,命令是:phpunti ./tests/单元测试文件名称.在phpstorm中使用phpunit需要做一些配置,指定composer的autoload.php就可以了.具体做法如下: 1.选择File->Setting->Languages&Framework->php->phpunit: 2.在phpunit liberay中选择 Use Composer autoloader: 3.在下面的框

PHP IDE PHPStorm配置支持友好Laravel代码提示方法

PHPStorm神器可以支持更友好的laravel框架代码提示(点击查看),只需要执行如下才做:第一步:在项目的composer.json中添加如下一行 代码如下: "require": { "laravel/framework": "5.0.*", "barryvdh/laravel-ide-helper":"dev-master" } 第二步:执行composer update 第三步:添加servic

Laravel创建项目和安装PHPStorm IDE插件

一.win10下安装composer1.下载composer.phar,放入php的安装目录https://getcomposer.org/download/1.4.2/composer.phar 2.新建 composer.bat 文件,并复制下列代码到文件中,然后执行,为了速度快,你可能要挂个代理 @php "%~dp0composer.phar" %* 3.为了保证composer的速度,使用国内镜像: composer config repo.packagist compose

phpstorm 调试 laravel

Reference: http://www.cnblogs.com/imayanlong/p/6375950.html,  https://segmentfault.com/a/1190000004505815 一.配置 Xdebug 配置 Xdebug 相关参数,在 php.ini 文件中新增如下配置,如果没安装的,请参考<PHP 安装 Xdebug扩展>: [xdebug] xdebug.remote_enable = on xdebug.remote_handler = dbgp xde

PHPStorm增加Laravel代码提示插件

1.安装laravel plugin 插件File -> Setting -> Plugins -> Browse Repositories -> 搜索框中输入 laravel plugin ,然后点击暗转 install 2.初始化项目的composer项目根目录 -> 右键 -> composer -> Init Composer 3.加载laravel-ide-helper插件 composer require --dev "barryvdh/la

phpstorm系列之laravel xdebug

1.xdebug 配置 zend_extension="/usr/local/opt/php56-xdebug/xdebug.so" xdebug.remote_autostart=On xdebug.remote_enable=On xdebug.remote_mode="req" xdebug.remote_host="localhost" xdebug.remote_port=9999 xdebug.remote_handler="