Phpstorm Yii

Posted : admin On 1/29/2022

XDebug with PHPStorm using Yii2 on Windows Debugging is an important tool in any language. But with the combination of PHP / YII2 and PHPSTORM, you have to go through few steps to get everything working. I am using PHPStorm 8.1, on Windows 10 using the latest version of the Yii2 framework through the composer. PhpStorm is ranked 2nd while Eclipse is ranked 15th. The most important reason people chose PhpStorm is: Supports Symfony2 (including Twig and Doctrine), Yii frameworks, and Laravel. PhpStorm is a commercial, cross-platform IDE (integrated development environment) for PHP, built by the Czech Republic-based company JetBrains. PhpStorm provides an editor for PHP, HTML and JavaScript with on-the-fly code analysis, error prevention and automated refactorings for PHP and JavaScript code.

In PhpStorm, you can run commands of several third-party command-line tools as well as define your own ones. As an example, let's integrate the Yii command line tool with PhpStorm.

  1. Create a new Composer project and choose to install the yiisoft/yii2-app-basic package.

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

  3. Click on the toolbar. In the Command Line Tools dialog, select Custom tool from the Choose tool list and set its visibility level to project.

  4. Click OK. In the Tool Settings dialog, provide the tool's main parameters. In our case, the tool is located under the project root, and we use the yii alias for it.

  5. Apply the changes and close the Settings/Preferences dialog. The tool xml definition will open in the editor.

  6. To use code completion for yii commands, we need to define them first in the xml tool descriptor.

    A command's definition is organized as follows:

    <command> <!--the command's container--> <name> <!--the command itself, mandatory, and non-empty--> </name> <help> <!--the command's help message, optional--> </help> <params> <!--the command's parameters and their default values--> </params> <optionsBefore> <!--the command's options container--> <option name=' shortcut='> <!--the option itself, mandatory, and non-empty; you can also provide a shorthand abbreviation and the usage pattern via attributes--> <help> <!--the command's help message, optional--> </help> </option> </optionsBefore> </command>

    Let's add a definition for a simple hello command, which echoes the entered argument. The command is executed via the following syntax:

    The resulting definition for this command should look as follows:

    <command> <name>hello</name> <help>Echoes the entered argument</help> <params>message</params> <optionsBefore> <option name='--appconfig'> <help> Custom application configuration file path. If not set, default application configuration is used. </help> </option> <option name='--color' pattern='equals'> <help> Boolean, 0 or 1. Enables or disables ANSI color in the output. If not set, ANSI color will only be enabled for terminals that support it. </help> </option> <option name='--help' shortcut='-h' pattern='equals'> <help> Boolean, 0 or 1. Defines whether to display help information about current command. </help> </option> <option name='--interactive' pattern='equals'> <help> Boolean, 0 or 1. Defines whether to run the command interactively. </help> </option> </optionsBefore> </command>
  7. The basic tool definition is ready. Select Tools Run Command form the main menu, or press Ctrl twice. In the Run Anything window that opens, type a command and press Enter.

You can find the full yii tool definition file in the yii2-phpstorm-commandlinetool GitHub repository. Have a look at other notable examples, too!

PhpStorm is an IDE (Integrated Development Environment) for PHP and web developers, which is engineered by JetBrains. It is not available free of cost. It supports PHP 5.3 and above versions. PhpStorm is built on the IntelliJ IDEA platform, which is written in Java.

JetBrains PhpStorm is an innovative and cross-platform IDE that become popular over the last couple of year. It is perfect for working with Drupal, Symfony, Laravel, WordPress, Zend Framework, Joomla, CakePHP, and other frameworks. PhpStorm 2019.1.3 is the latest version of the PhpStorm.

All WebStorm features are included into PhpStorm, with full-fledged support for PHP and database support added on the top. PhpStorm helps the developer to understand and change their code by providing editable UML class diagrams for PHP code.

PhpStorm IDE provides code refactoring, auto-completion, on-the-fly error prevention, zero-configuration debugging, and an extended HTML, CSS, and JavaScript editor.

PhpStorm provides tools and code assistance features for working with databases and SQL in your projects. It connects with the database, edit tables and schemas, run queries, and even analyze schema with UML diagram.

Note: PhpStorm is not free of cost. It is available for 30 days free trial.

Key Features of PhpStorm

  • Complete development environment
    Most PHP developers do not work with PHP only, but they also work with HTML, CSS, JavaScript, and other languages. PhpStorm makes it easy for developers to work with all languages, by providing code completion and syntax highlighting support.
  • Support multiple PHP Framework
    PhpStorm is a perfect choice if you use PHP frameworks. It integrates effectively with lots of framework like Laravel, CakePHP, Symfony2, and Yii - all of these frameworks are also supported by Future Hosting?s PHP Framework application server.
  • Great version control Integration
    PhpStorm provides full support for a large range of version control system, most importantly included - GitHub and Git. Programmers can branch and merge from within the IDE.
    Additionally, PhpStorm also includes excellent FTP support that the code can be uploaded to a remote server within a few seconds.
  • Database Support
    PhpStorm provides tools and code assistance features for working with SQL and databases in your projects. It connects with the database, edits table data, executes queries, and even analyzes the schemas with UML diagrams.
  • Debugging and Testing
    Zero-configuration debugging makes it easy to debug the application. PHPUnit supports to develop and run unit tests right from your IDE. Profile the applications with Xdebug and Zend Debugger and check aggregated reports in PhpStorm.

PhpStorm 10


PhpStorm includes a number of new features that make PHP-based application more pleasant. First and foremost feature of PhpStorm is that it offers full support for PHP 7, another exciting new feature is the Docker integration. Developers can easily handle Docker containers from inside the IDE. It is the powerful feature of PhpStorm 10 that makes it easy to build development and deployment environment which can run almost on any Linux server.

Phpstorm Yii2 Setup

Benefits of using PhpStorm

  • Projects are scanned quickly and accurately in PhpStorm. We are able to perform auto-compilation based on existing class and functions really fast.
  • Excellent project-wide search option.
  • Best tracing option for inheritance.
  • Search has lots of options and searchable. We can organize the search result according to file, directory, and other several options.
  • Excellent built-in comparison tool with syntax highlighting.
  • Clear matching brace highlight available.
  • Useful alert available, which pop up over the editor to tells us that something might not be configured properly.

System requirements for PhpStorm

  • Minimum 2GB RAM
  • 4GB recommended
  • Window 10/8/7/Vista/XP (64 bit)
  • 1024x768 screen resolution.

How to install PhpStorm

Step 1: Download the latest version of JetBrains PhpStorm 2019.1.3 from the following link for 30 days free trial. You can choose any platform (Window, Linux, and MacOS) as per your need.

Step 2: Once the downloading completes, run the PhpStorm. We will get the wizard where we need to click on Next button.

Step 3: Browse the Destination Folder to install PhpStorm and click on Next.

Step 3: Here, we don't need to do anything, click on Next and move forward. But for creating a shortcut on Desktop check the create Desktop Shortcut as per the system configuration.

Step 4: Select/Enter the start menu folder name for creating the program's shortcut. By default, JetBrains will show. Now click on Install Button and start the extraction of files.

Step 5: Once all the files are extracted successfully, click on the Run PhpStorm checkbox and click on Finish to complete the installation process.

Phpstorm Yii

Step 6: A wizard will show to import the PhpStorm setting. Select do not import setting and press OK.

Step 7: Now, accept the term of User Agreement and Continue.

Step 8: Click on Send Usage statistics and move forward.

Step 9: Set the UI theme from here (as per below image), for dark theme select Darcula and for light theme choose Light. We can also skip this step by clicking on Skip Remaining and Set Default.

Step 10: Skip this step for later by clicking on Skip Remaining and Set Default button.

Step 11: For 30 days free trial, select Evaluate for free rather than Activate and click on Evaluate.

Phpstorm Iis

Step 12: PhpStorm is successfully installed. Now, create a new project and start work with PhpStorm.

How to create a project in PhpStorm

Step 1: Create a new project with PhpStorm and also provide the location to save.

Step 2: Right click on your project to create a new HTML file. New → HTML, we can also create PHP, JavaScript, and other files here.

Step 3: Write the HTML code and run it on browser.

Phpstorm Yii

Step 4: The output of the above program will be-