Phpstorm Lumen



Phpstorm environment variables

Since Lumen does not support auto-discovery, you will have to register them individually depending on which features you want to use. Check Lighthouse's composer.json, the section extra.laravel.providers contains the default service providers. Further, when I work with Laravel, or Lumen, I would like the plugin to ignore the vendor folder and all files inside of it. This is achieved by adding the folder to the ignore list, with the following syntax vendor/. And here’s how the plugin will display that: That’s it peeps. Hit CTRL+S and enjoy the auto-magic formatting. It says specify the name of the script you want to use in the terminal. By default it choose “pstorm” and we can change it, but it’s ok for me. After this we can open any file or project from. This can be useful for cases you want to take advantage the PhpStorm also supports the directory.phpstorm.meta.php/ which would parse any file places there, should your want provide additional files to PhpStorm. Usage with Lumen. This package is focused on Laravel development, but it can also be used in Lumen with some workarounds.

Laravel is a free, open source PHP web application framework. It is built on top of several Symfony components, and makes common tasks such as authentication, routing, sessions and caching much easier to implement.

Before you start working with Laravel, make sure that either the Laravel (free) or Laravel Idea (paid) plugins are installed and enabled. Both plugins additionally require installing the Laravel IDE helper tool.

Additionally, make sure Composer is installed on your machine and initialized in the current project as described in Composer dependency manager.

Watch this video to get a quick overview on Laravel support in PhpStorm:

Phpstorm Environment Variables

Install Laravel IDE helper generator

  1. Install Laravel IDE helper generator with Composer. To do this, add a dependency for the barryvdh/laravel-ide-helper package to composer.json. Refer to Install dependencies for details.

  2. Add Laravel IDE helper as a ServiceProvider into the application. In the config/app.php file, add BarryvdhLaravelIdeHelperIdeHelperServiceProvider::class under the providers element:

    return array( // ... 'providers' => array( // ... // Laravel IDE helper 'BarryvdhLaravelIdeHelperIdeHelperServiceProvider::class', ), // ... );

The Laravel IDE Helper may have to be run after changing or adding services, controllers, models and views. Alternatively, set up File watchers in PhpStorm to automatically regenerate this file when, for example, composer.json is updated.

You can also install the Laravel generators Composer package to add various Laravel generators for models, views, controllers, and much more.

Coding assistance

The Laravel plugin provides code completion and navigation for various Laravel components: controllers, routes, views, configuration, services, and translations. You can also use Laravel-specific live templates for generating various Laravel entities.

This section describes coding assistance provided by the Laravel plugin. For details on working with the Laravel Idea plugin, see the official documentation.

Code completion

In the editor, press Ctrl+Space to invoke code completion and do any of the following:

  • Reference a controller when using the Redirect and Route facade's various functions:

  • Reference a Blade template (or view) when using the View facade:

  • Reference various keys that are defined in our application's settings when using the Configuration facade:

  • Complete various translation keys when using the Lang and calling Lang::get():

Code navigation

To navigate to the declaration of an item, position the caret at its usage and press Ctrl+B. Alternatively, Ctrl+Click the usage.

  • Navigate to the controller's declaration:

  • Navigate to a Blade template (or view) declaration:

  • Navigate to the declaration of a configuration entry or a service:

  • Navigate to the declaration of a translation key:

Generate code with Live Templates

PhpStorm provides numerous code generation facilities. After downloading and installing the PhpStorm Laravel Live Templates, you can extend the standard live templates set with Laravel-specific live templates, such as:

  • Blade directives

  • Input and Request snippets

  • Cookie snippets

  • Route snippets and generation

  • View, Response and Redirect templates

  • Building schema (includes column types)

  • Cache

  • Form and session snippets

  • Snippets calling various helpers

Blade templates support

Before you start, make sure the Blade plugin is installed and enabled. The Blade plugin is bundled with PhpStorm and activated by default. If the plugin is disabled, enable it on the Settings/Preferences | Plugins page as described in Managing plugins.

PhpStorm provides full support of the Laravel Blade template engine. It highlights various Blade syntax constructs, as well as any HTML, JavaScript and CSS code inside the templates.

Besides syntax highlighting, PhpStorm provides several other Blade-specific features.

Phpstorm Lumen

Code completion for braces and directives

PhpStorm's editor provides code completion both for standard and custom Blade directives, which can be defined In the Settings/Preferences dialog Ctrl+Alt+S under PHP | Blade.

When @for or @foreach directives are used, variable introduction with code completion is available inside the construct's body.

Sections support

While working on a Blade template, you can open a section using the @section directive. PhpStorm provides code completion Ctrl+Space for all known sections' names in the project.

PhpStorm provides the code inspection that detects the sections that are not closed using the @stop directive.

To navigate to the declaration of a section, position the caret at its usage and press Ctrl+B. Alternatively, Ctrl+Click the usage.

The Laravel plugin also adds a marker to the editor gutter, which lets you navigate to the parent section.

Code completion and navigation for extends and includes

Blade templates are often composed of various includes of small reusable blocks, which are in turn other templates. You can also extend templates and provide content for additional sections. PhpStorm and the Laravel plugin provide completion for template names in both the @extends and the @include directives. Completion suggestions include template directory names as well as full template names.

To navigate to the declaration of a template, position the caret at its usage and press Ctrl+B. Alternatively, Ctrl+Click the usage.

Use Alt+F7 to quickly find all template usages in the project.

Language injection in Blade templates

When working with Blade templates, you can inject code fragments inside the template blocks. PhpStorm will provide you with comprehensive language assistance for editing that code fragment.

Inject JavaScript or CSS into a Blade template section automatically

PhpStorm can automatically inject code into Blade template sections based on the defined injection rules. Out of the box, the rules for automatically injecting JavaScript and CSS code are available.

  • In a Blade template, add a section named javascript (to inject JavaScript) or css (to inject CSS) as follows:

    @section('javascript') // injected JavaScript code @stop @section('css') // injected CSS code @stop

    PhpStorm will automatically inject JavaScript or CSS into the template sections.

Debug Blade templates

You can debug Blade templates using the same techniques as for regular PHP files.

Debugging Blade templates is supported for Laravel 5.8 or later.

Enable Blade debugging

  1. In the Settings/Preferences dialog Ctrl+Alt+S, go to PHP | Debug | Templates and expand the Blade Debug area.

  2. In the Cache path field, provide the path to the Blade compiled templates cache folder. Type the path manually or click and select the relevant folder in the dialog that opens.

Start a debugging session

Start a debugging session as described in the Ultimate debugging guide. The easiest and recommended approach is to use Zero-configuration debugging:

  1. Choose and install the browser extension suitable for your browser.

  2. On the PhpStorm toolbar, toggle to start listening for incoming PHP debug connections, or choose Run | Start Listening for PHP Debug Connections from the main menu.

  3. Set a breakpoint in your code.

  4. Start the debugging session in the browser using the installed browser extension.

  5. During a debugging session, examine the program state: see variable values, evaluate expressions, step through the program, and so on.

See Zero-configuration debugging for the detailed step-by-step instructions, and Advanced debugging scenarios for more debugging scenarios.

Configure Blade templates

Add, modify, or remove Blade directives

Blade directives are managed on the Directives tab of the Blade Page. The tab lists all the currently available Blade directives, for those that have parameters, the prefixes and suffixes are also shown. When you start, the list contains only predefined directives. You can edit these directives as well as create custom ones.

  1. In the Settings/Preferences dialog Ctrl+Alt+S, go to PHP | Blade.

  2. On the Blade page that opens, switch to the Directives tab, which shows a list of all currently available directives.

    • To define a new directive, click and specify the directive's name in the Name field.

      If the new directives requires a prefix and a suffix, select the Has parameter checkbox and type the prefix and suffix to use in the Prefix and Suffix fields respectively. PhpStorm will automatically enclose the prefix and suffix in opening and closing brackets and quotes and add a colon separator : so the parameters will look as follows: ('<prefix>:<suffix>').

    • To edit an existing directive, select it in the list and change the values in the fields below.

      To restore the original definition, click .

    • To remove a directive from the list, select it and click .

Configure Blade delimiters

PhpStorm recognizes Blade templates and provides error highlighting and code completion for them based on the delimiters you specify.

  1. In the Settings/Preferences dialog Ctrl+Alt+S, go to PHP | Blade.

  2. On the Blade page that opens, switch to the Text Tags. The fields in the tab show the opening and closing characters for raw tags, content tags, and escaped tags.

  3. The fields are filled in with the default values in compliance with Blade Templates 5.8. If you are using an earlier version, you can specify the relevant custom delimiters and PhpStorm will provide coding assistance according to the new rules.

Use the Artisan command line tool from PhpStorm

PhpStorm integrates with the Artisan command-line interface, which is included with Laravel and provides several handy commands.

Configure Artisan automatically

  • On project opening, PhpStorm will detect and configure Artisan and display the notification in the Composer Log.

    If you want to customize the tool, click to quickly jump to the Command Line Tool Support settings page.

    On Windows, automatic Artisan detection requires a configured local PHP interpreter.

Configure Artisan manually

  1. In the Settings/Preferences dialog Ctrl+Alt+S, go to Tools | Command Line Tool Support.

  2. Click on the toolbar.

  3. In the Command Line Tools dialog, choose Laravel from the list, and specify its visibility level (Project or Global ).

  4. When you click OK, the tool settings dialog opens.

    Specify the tool alias, provide the path to artisan, and choose one of the configured PHP interpreters from the PHP Interpreter list. See Configure local PHP interpreters and Configure remote PHP interpreters for details.

  5. Click OK to apply changes and return to the Command Line Tool Support page. Optionally, click to edit the tool properties, or to customize the commands set. See Customize a tool for details.

You can now run the artisan ide-helper:generate command to generate the required PHPDoc information. PhpStorm and the Laravel plugin will use this information to provide code completion and navigation.

Run Artisan commands

  • From the main menu, choose Tools | Run Command or press Ctrl twice.

    In the Run Anything window that opens, type the call of the command in the <artisan> <command> format.

    The command execution result is displayed in the Run tool window.

Terminate a command

  • Click on the Run tool window toolbar.

Debug Artisan commands

Laravel commands are defined in controller classes that extend Command. To debug a command, it is crucial that you initiate a debugging session for the command itself, and not the controller class file it is defined in. Otherwise, the Laravel bootstrapping process will be skipped, and the execution will fail.

  1. In the controller class corresponding to the selected command, click the editor gutter at a code line where you want to set a breakpoint.

  2. Create a run/debug configuration that will run the artisan tool with the selected command. In the main menu, select Run | Edit Configurations, then click and choose PHP Script from the list.

  3. In the PHP Script dialog, provide the run/debug configuration parameters.

    • In the File field, provide the path to the artisan executable file.

    • In the Arguments field, type the actual command and its arguments, such as view:cache.

  4. On the PhpStorm toolbar, select the created run/debug configuration and click . The command execution will stop at the specified breakpoint.

Lua

PhpStorm uses run/debug configurations to run, debug, and test your code. Each configuration is a named set of run/debug startup properties.

If the Navigation bar is visible (View | Appearance | Navigation Bar ), you can access all available run/debug configurations from the selector on the toolbar.

Run/debug configurations can be created as:

  • Temporary – created every time you select Run <item_name> from the context menu. To call the context menu, right-click an object or an area.
    The maximum number of temporary configurations is 5, the older ones are automatically deleted when new ones are added.

  • Permanent – created explicitly from a template or by saving a temporary configuration. Permanent configurations remain as part of your project until you remove them.

So whenever you run/debug or test your code, PhpStorm either uses an existing permanent run/debug configuration or creates a new temporary one.

Permanent configurations have opaque icons while the icons of temporary configurations are semi-transparent.

Create permanent run/debug configurations

PhpStorm provides the following ways to create a permanent run/debug configuration:

  • Save a temporary run/debug configuration as permanent.

  • Create from a template or copy an existing configuration.

Save a temporary configuration as permanent

  • Select a temporary configuration in the run/debug configuration switcher and then click Save Configuration.

  • Alternatively, select a temporary configuration in the Run/debug configurations dialog and click on the toolbar.

PhpStorm provides run/debug configuration templates for different languages, tools, and frameworks. The list of available templates varies depending on the installed/bundled plugins.

Create a run/debug configuration from a template

  1. Open the Run/Debug Configuration dialog in one of the following ways:

    • Select Run | Edit Configurations from the main menu.

    • With the Navigation bar visible (View | Appearance | Navigation Bar ), choose Edit Configurations from the run/debug configuration selector.

    • Press Alt+Shift+F10, then press 0 or select the configuration from the popup and press F4.

  2. In the Run/Debug Configuration dialog, click on the toolbar or press Alt+Insert. The list shows the run/debug configuration templates.

    Select the desired template. If you are not sure which template to choose, refer to Run/debug configurations dialog for more information on particular templates.

  3. Specify the run/debug configuration name in the Name field. This name will be shown in the list of the available run/debug configurations.

  4. Select Allow parallel run if you want to allow multiple instances of the configuration to run at the same time. If this option is disabled, attempting to re-run the configuration will terminate the active session.

  5. Set the run/debug configuration parameters. The list of mandatory and optional parameters may vary depending on the selected run/debug configuration type.

    For the detailed description of the selected template, see the respective section of run/debug configurations reference.

  6. In the Before launch section, define whether you want to perform any specific actions before launching the application, for example, execute some tools or scripts prior to launching the run/debug configuration.

    For information on particular Before launch activities, refer to Before Launch

  7. Apply the changes and close the dialog.

Share run/debug configurations

If you are working in a team, you might want to share your run/debug configurations so that your teammates could run the application using the same configuration or enable them to remotely attach to the process you are running.

For these purposes, PhpStorm provides a mechanism to store your run/debug configurations as project files and share them through VCS. The same mechanism can also be used when you want to send your configuration as a file to someone else. This saves a lot of time as run/debug configurations sometimes get sophisticated, and keeping them in sync manually would be tedious and error-prone.

Legacy .ipr -based projects do not support individual run/debug configurations. With legacy projects, you can only share all configurations at once by adding the .ipr file to the VCS.

  1. From the main menu, select Run | Edit Configurations. Alternatively, press Alt+Shift+F10, then 0.

  2. Select the run/debug configuration you want to share, enable the Store as project file option, and specify the location where the configuration file will be stored.

    If compatibility with PhpStorm 2019.3 and earlier is required, store the file in the default location.

  3. (Optional) If the .idea directory is added to VCS ignored files, the .idea/runConfigurations subfolder will be ignored, too. If you use Git for your project, you can share .idea/runConfigurations only and leave .idea ignored by modifying .gitignore as follows:

Turning on the Store as project file option does not submit anything to the VCS for you. For run/debug configurations to make their way to a shared repository, you have to check them in like other versioned files.

To learn how to use version control systems in PhpStorm, refer to the Version control section.

Run/debug configuration templates

Each type of run/debug configuration is a template that you can edit, so the next time you create a new configuration of that type, its parameters already have the desired values.

Changing the default values of a template does not affect already existing run/debug configurations.

Configure the default values for a template

  1. From the main menu, select Run | Edit Configurations. Alternatively, press Alt+Shift+F10, then 0.

  2. In the left-hand pane of the run/debug configuration dialog, click Edit configuration templates.

  3. In the Run/Debug Configuration Templates dialog that opens, select a configuration type.

  4. Specify the desired default parameters and click OK to save the template.

Compound run/debug configurations

Suppose you would like to launch multiple run/debug configurations simultaneously. For example, you may want to run several configurations of different types or a sequence of several test configurations. You can configure this behavior with a compound run/debug configuration.

When you run or debug your code using a compound configuration, you actually launch a sequence of configurations in the order they are listed.

Create a compound run/debug configuration

  1. From the main menu, select Run | Edit Configurations. Alternatively, press Alt+Shift+F10, then 0.

  2. In the Run/Debug Configurations dialog, click or press Alt+Insert, then select Compound.

  3. Specify the run/debug configuration name in the Name field. This name will be shown in the list of the available run/debug configurations.

  4. Select Store as project file to make this run/debug configuration available to other team members.

  5. To include a new run/debug configuration into the compound configuration, click Add and select the desired one from the list.

  6. Apply the changes.

Run/debug configuration folders

Phpstorm

When there are many run/debug configurations of the same type, you can group them in folders so they become easier to distinguish visually.

Once grouped, the run/debug configurations appear in the list under the corresponding folders.

Create a folder for run/debug configurations

  1. From the main menu, select Run | Edit Configurations. Alternatively, press Alt+Shift+F10, then 0.

  2. In the Run/Debug Configurations dialog, select a configuration type and click on the toolbar. A new empty folder for the selected type is created.

  3. Specify the folder name in the text field to the right or accept the default name.

  4. Select the desired run/debug configurations and move them under the target folder.

  5. Apply the changes. If a folder is empty, it will not be saved.

When you no longer need a folder, you can delete it Delete. The run/debug configurations grouped under this folder will be moved under the root of the corresponding run/debug configuration type.

Run/Debug configurations in the Services tool window

You can manage multiple run/debug configurations in the Services tool window. For example, you can start, pause, and stop several applications, track their status, and examine application-specific details.

Add Run/Debug configurations to the Services window

Phpstorm Lumens

  1. Select View | Tool Windows | Services from the main menu or press Alt+8.

  2. In the Services tool window, click Add service, then select Run Configuration Type.

  3. Select a run/debug configuration type from the list to add all configurations of this type to the window.

    Note that the tool window will only display the configuration types for which you have created one or more configurations.

Phpstorm Lumen Download

Last modified: 21 April 2021