Laravel Development using PhpStorm

LaravelLots of PHP developers create their applications using Laravel, a free, open source PHP web application framework. It is built on top of several Symfony components, and provides a development framework that makes common tasks such as authentication, routing, sessions and caching much easier to implement.

Last summer, we introduced support for Blade, the template language used by Laravel. Support for artisan, the command line tool for Laravel developers, is baked into PhpStorm as well. Using the Laravel plugin and the Laravel IDE helper, we can further extend PhpStorm’s support for Laravel applications. Let’s see how!

The Laravel IDE Helper

After making sure Composer is available for use in our project, we can install the Laravel IDE helper into our project using the Composer | Add dependency… context menu. We can search for barryvdh/laravel-ide-helper and click Install to download the package and add it to our project.

After registering the ‘Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider’ service provider in our application and running artisan ide-helper:generate, PhpStorm will have code completion support and syntax highlighting for many of Laravel’s facades.

The Laravel Plugin for PhpStorm

To further enhance the Laravel experience, we can also install the Laravel Plugin. Under Settings (Preferences) | Plugins, click the Browse repositories… button and search for Laravel. The Install plugin button will download and install the plugin into our IDE.

Restart the IDE and enable the plugin under Settings (Preferences) | Other Settings | Laravel Plugin | Enable Plugin for this Project. All of a sudden, PhpStorm will know what all Laravel facades do, and provide code completion for controllers, views, routes, configuration, translations and many other things!

Laravel facade - code completion

There’s not only code completion… We can navigate to these items as well!  Using Ctrl+Click (CMD+Click on Mac OS X) or Go To Declaration (Ctrl+B / CMD+B), PhpStorm will navigate us to where, for example, a configuration entry is declared.

Laravel navigation features

Working in Blade templates? The Laravel plugin also enhances that experience, for example with code completion for @section directives.

Section directives code completion for Laravel in PhpStorm

Anxious to learn more? Check our Laravel tutorial, which covers getting PhpStorm ready for Laravel development, code completion, navigation, automatic code inspections, command line tool support, debugging and unit testing!

Are you a Laravel developer? Give PhpStorm 8 a try! We have an elaborate tutorial on Laravel support in PhpStorm which will help you get the most out of our IDE. Your feedback is very welcome through the issue tracker, by posting in the comments below, or in our forums!

Develop with pleasure!
– JetBrains PhpStorm Team

This entry was posted in Cool Feature and tagged , , , . Bookmark the permalink.
  • http://tbergeron.com/ Tommy Bergeron

    The Laravel plugin don’t work for me on the latest version. I get:

    12:17:00 PM IllegalArgumentException: Argument for @NotNull parameter ‘ancestor’ of com/intellij/openapi/vfs/VfsUtilCore.getRelativePath must not be null
    12:17:19 PM IllegalArgumentException: Argument for @NotNull parameter ‘ancestor’ of com/intellij/openapi/vfs/VfsUtilCore.getRelativePath must not be null

    I cannot set a “views” directory, I can activate the plugin for the project but nothing really happens no auto-suggestion for routes or views whatsoever. Anyone else? Ideas?

    EDIT: Got it to work by loading another project, trying it out there and then coming back my other project and everything was working. That Config::get and URL::route() are WONDERFUL! http://d.pr/i/XvEw Thanks to whoever contributed the plugin!

  • Jeroen Noten

    The plugin does not seem to work for me.. any ideas why? I did enable it for the project.

    • Maxim Kolmakov

      Please check that your plugin version is 0.7.2.

      • Jeroen Noten

        Thanks for your reply. I have version 0.7.2.

        • Maxim Kolmakov

          Could you please create an issue at: https://youtrack.jetbrains.com/issues/WI#newissue and attach idea.log (Help->Show Log in…) there?

          • Jeroen Noten

            Oh, it does work well now, after enabling AutoPopup for completion. Thanks anyway!

  • goyote8

    It doesn’t work with the latest EAP, can you guys make sure it works before doing a blog post about it?

    • Maxim Kolmakov

      Please check that your plugin version is 0.7.2

  • Zoran Knezevic

    it does not work

    • Maxim Kolmakov

      Please check that your Laravel plugin version is 0.7.2.

  • g8ndra

    It doesnt work

    • Maxim Kolmakov

      Please check that your Laravel plugin has version 0.7.2.

  • Stefan Kecskes

    It works perfectly. I use PhpStorm 8.0.2, barryvdh/laravel-ide-helper v1.11.3 and Laravel plugin 0.7.2 in Laravel 4 project. Thanks a lot.

  • Joaquin

    Works like a charm, it just makes laravel even easier

    I love PhpStorm! <3

  • http://ixqus.com/ IXQUS

    I’ve been debugging with PHPStorm and Laravel, for about a year. Most of that has been in Windows. Debugging through Laravel, with PHPStorm, is fairly straightforward. However, there are some cases where it isn’t. It would be nice to see a troubleshooting section for debugging issues commonly encountered, when running through a framework like Laravel (e.g. xdebug.ini checklist, checklist to validate path mapping, and the like). Another thing that would be nice is a link in the docs to a well-defined .gitignore file for PHPStorm projects and Laravel. Once you know the ropes, it’s fairly trivial to put it all together, but it’s quite time-consuming and a bit confusing, if you’re a newcomer.

    The last three days, I’ve been having an issue with breakpoints not being hit, after cloning a Laravel project that I’ve been debugging in Windows, on OS X (homebrew nginx 1.6.2 + php-fpm 5.5 + xdebug 2.2.7). XDebug is configured for xdebug.remote_autostart=1 and xdebug.remote_connect_back=1, as my preference is to always hit breakpoints I’ve set, if the IDE is listening for debug connections. As I’ve only tested this issue with existing code, I’m not sure if this also applies to a vanilla Laravel install.

    Specifically, when using Laravel’s App::missing(function($exception) { /* callback code here */ })); to deal with redirecting links being deprecated or displaying a templated 404, I was able to get breakpoints to hit only one time, on the first page load, and it would fail to hit breakpoints on subsequent page loads.

    This was an issue with the default Laravel 4 cache driver ‘file’, in the local debugging environment. The fix is to have a copy of app/config/cache.php in app/config/local/cache.php file with the cache driver set to ‘array’. Breakpoints work as expected, now; with xdebug configured for zero-configuration debugging. As I’ve only been testing the App::missing() callback for the framework, I can’t say if this cache driver affects any other debugging scenarios.

    • Maxim Kolmakov

      There is “Validate Remote Environment” (please see http://blog.jetbrains.com/phpstorm/2013/08/debugger-configuration-validation-with-phpstorm/) that checks your ini files and mappings.
      The configuration of framework based project and usual project for debugging is almost always the same except some tricks with caching that you’ve described (which is hard to validate from our side).

      Do I understand you correctly, that you’ve managed to resolve your issue with Laravel debugging?

      • http://ixqus.com/ IXQUS

        Yes, I resolved the issue. Validate Remote Environment worked, when I was having issues. What resolved the problem where breakpoints wouldn’t hit was to set the Laravel cache driver from ‘file’ to ‘array’.

  • Adam Klein

    The plugin works for the most part, but I was unable to get the auto-completion to work on the blade templates. any ideas of how to get this to work properly? I am using PHPStorm 8.0.3 EAP.

  • Jakk

    phpstorm 8.0.3 with laravel 5 doesnt works…

  • Adnan Siddiqi

    In Ruby Mine I have builtin support of Generators. Will this Plugin help to run Artisan command within IDE?

  • Hans

    Code completion is broken with Laravel 5, Laravel plugin 0.7.2 and barryvdh/laravel-ide-helper 2.0.0

  • Денис Киселёв

    Why laravel plugin (v. 0.7.2) get me full namespace path to controller?