Note: This article applies to the current version of PhpStorm, version 8. For prior versions, please click here.
It's been two years since our last visit with PhpStorm. Several items have changed and we'll cover how to get up and running with the latest version. PhpStorm 8 is a cross-platform, IDE (Integrated Development Environment) that delivers a feature packed, fast, and efficient user interface for debugging and code editing. As a commercial product, you will find the runtime to be fast and what you would expect from a well written native application. While still requiring a Java runtime, PhpStorm feels much faster than eclipse or even the lighter weight Netbeans IDE. Like Netbeans, it works with either DesktopServer Limited or DesktopServer Premium editions. It also provides all the common editing features you would expect to find in a professional IDE: code folding, code completion, debugging with breakpoints and step functions, variable watch lists and inspectors, and multiple disciplines for syntax highlighting (JavaScript, HTML, PHP, etc. with an emphasis on PHP). Since WordPress ‘template tags' are just PHP functions, PhpStorm can make working with WordPress fast and efficient. Now PHPStorm features WordPress specific settings for code styling and an intelligent WordPress API for autocomplete while coding. However, setup is still a challenge as the new version 8 user interface can be misleading and is broken in a key area. But we have a workaround! Don't let the 'nuance' (bug) detour you as PhpStorm is fully functional, albeit in need of a few workarounds. In this post, I will help you simplify the initial setup process of using PhpStorm with DesktopServer to give you a fast and professional IDE for WordPress development. Once acclimated, users will find version 8 debugging quick, robust and more responsive than ever.
Getting Started
Welcome to the JetBrains marketplace.
Download jetbrains phpstorm 8.0.2 for free. Development Tools downloads - JetBrains PhpStorm by JetBrains s.r.o and many more programs are available for instant and free download. PHPStorm(8) on my Host. CentOS as my Guest (vagrant) Tested on Ubuntu and Mac Host; I started first by setting the global settings. This way, all new projects will inherit the default settings. Currently setup projects will need to apply the global settings for this to work. If you have not setup your default interpreter already, you should do.
If you haven't already installed PhpStorm, you can find a free, fully functional 30 day trial for either Macintosh or Windows from their website at http://www.jetbrains.com/phpstorm/. The installer is typical and straight forward. Simply install using the defaults. To work with DesktopServer, make sure you have checked the ‘Enable debug services' check box in DesktopServer. You can find this setting in DesktopServer's first main menu option ‘Stop or restart…'. Be sure to select the ‘Restart' option followed by clicking the ‘Next' button.
Create New Project from Existing Files
If you haven't already created a DesktopServer website, take a moment to try the simple www.example.dev website as outlined in 'Getting Started with DesktopServer', steps 1 to 10. Adding your existing website to PhpStorm requires a few extra steps. The newest version of PhpStorm has a bug that prevents you from creating a website with existing source on startup (the option is disabled). It will enable if you create or open an existing project and close it immediately. But avoid this faux pas altogether and save time by just selecting the first enabled option to 'Create a New Project'. We can specify our existing source files anyway.
Use the '…' button to bring up a folder selection dialog box. Navigate to your project's site root folder. I.e. example, if your website is www.example.dev, the site root folder would be called www.example.dev and exist in your Documents/Websites folder. Select the 'www.example.dev' folder and be sure to set the Project type to 'Empty project'.
We'll work around PhpStorm's broken user interface that prevents us from selecting the '…existing files' option. After providing the path to your files, PhpStorm 8 will sense that you have existing source code files at the given location. Be sure to click the 'Yes' button to keep your project's files. PhpStorm will then start indexing all the existing project files and a progress bar will appear in the status bar at the bottom of the editor. Be sure to be patient and let this process complete as it is necessary to leverage PhpStorm's useful code navigation and syntax checking features.
You will see a few prompts in the status bar after PhpStorm completes indexing. Click on the status bar to bring up the prompts for WordPress support and code styling. Enabling these features should autocomplete features when coding for the WordPress API as well as code indentation and styling that matches common WordPress' coding standards.
Now you will need to create a PHP Web Application configuration. Start by clicking the drop down arrow in the upper right hand corner of the application and select the drop down menu for 'Edit Configurations'. A dialog will appear titled 'Run/Debug Configuration'. Click the plus symbol in the upper left corner of the dialog and select 'PHP Web Application' from the drop down list of options.
Next, define the server configuration. Type the a name (we'd suggest this match your DesktopServer project's domain, i.e. www.example.dev). Click the checkbox 'Single Instance Only', followed by clicking the '…' button next to the 'Server' field to define a server. A dialog box (titled 'Servers') will appear allowing you to define a new development server. Click the '+' button in the upper left corner of the 'Servers' dialog box. You can specify a server and hostname (i.e. www.example.dev). The hostname must match your DesktopServer domain name (i.e. www.example.dev). Lastly, click the 'OK' button to close the dialog box. Ensure the 'Run/Debug Configuration' window has the 'Server' field set and click 'OK' to close the 'Run/Debug Configuration' window.
Debugging WordPress in PhpStorm
PhpStorm 8′s debugging feature is somewhat more intuitive than in prior configurations. This setup doesn't need the nonsensical, two-steps, 'listening' button; you can just click the 'debug' button to begin debugging. However by default, PhpStorm will stall at the first line of code within the site's root index.php. Program execution always starts with index.php in the site root, but constantly opening that file and pausing there can quickly become annoying. We would suggest changing the default setting on startup to be even less cumbersome with less steps and clicks to start debugging your code.
Start by navigating to the Preferences (Macintosh) or Settings (Windows) dialog window. On Macintosh, this will be under the application pull down menu for PhpStorm -> Preferences. On Microsoft Windows, the pull down menu for File -> Settings. Navigate PhpStorm's massively extensive tree menu on the left side to the location for Language and Frameworks -> PHP -> Debug. Uncheck the options for 'Force break at the first line when no path mapping is specified' as well as the option for 'Force break at the first line when a script is outside the project'. Click the 'OK' button to dismiss the Preferences/Settings window. You can now start debugging your projects faster when setting custom break points to find bugs or check program flow. Please see the following paragraphs (below) for debugging examples.
What's a Breakpoint?
Phpstorm 8 Free Download
A breakpoint is an intentional stopping or pausing of program execution put in place by the programmer for the purpose of debugging. As a web developer, you can pause execution of your WordPress application before it is completely transmitted to the web browser for display. Breakpoints can only be created in PhpStorm within source code files (.php files) on lines that contain PHP code. A computer programmer may wish to do this to suspend program flow and check on variables before, after, or during the program's flow. Watching the program flow can also be accomplished to better understand how the program branches off between source code files, within plugins, themes, or to detect possible errors within any of the aforementioned files that may be causing unintended results.
Creating a breakout
To set a breakpoint, click in the margin just left of the line of code you wish to pause execution on. In our example, we first open the index.php file from the site root of our development project (see step 1 – Open the index file). Next, we place a breakpoint on the line that reads 'require( dirname( __FILE__ ) . '/wp-blog-header.php' );
' (see step 2 – Click the margin to set a breakpoint). When a breakpoint is set, the entire line will highlight in read. To begin the debugging process, click the toolbar icon that resembles a bug (see step 3 – Click the debug icon to start debugging). When a breakpoint is encountered during program execution, the red line of the breakpoint will transform and highlight in blue indicating that the instruction pointer is paused on the breakpoint line. Lastly, you may use the icons to control the program flow (see step 4 – Use the toolbar buttons to control program flow…). While a breakpoint is paused, you will note that the browser will be 'stuck' waiting for the page to complete loading. The green arrow will resume program execution and send the content to the browser window. In contrast, the red square stop icon will end the debug process and abort sending the page to the web browser (which will immediately timeout). In addition to the left side vertical buttons, you will see the 'step' buttons laid out horizontally. These buttons allow you to move one line at a time through the program execution.
Navigating Code and Breakpoints
When stopped at a breakpoint, you can advance one line at a time using the step buttons to execute a line of PHP code sequentially one line (aka 'step') at a time. If you encounter a PHP defined function, you may use the 'Step Into' button to automatically open the file where the function is defined and step through the lines of PHP code that exists to define the function (see 1, Use 'Step Into' button…). Even when not running in debug mode, PhpStorm 8 makes navigating code easy; PHP functions can be right-clicked (Cntrl+Click on Macintosh) to bring up a popup context menu to automatically go to the source code that defines the given function. PhpStorm will automatically move the cursor to the function declaration and open the associated source code file if it is not already open (see 2, Right-click a PHP function and select Go To -> Declaration). For example, we have opened the index.php file for the current theme. You can find this file for the Twenty Fourteen theme in the theme's subfolder. I.e. at /wp-content/themes/twentyfourteen/index.php. Place the cursor within the function has_posts()
and right-click the function. Follow the popup menu for Go To -> Declaration. PhpStorm will automatically locate and open the query.php file where the function is declared and place the cursor at the precise location of the function definition.
Now that you are armed with the knowledge of how to set breakpoints and navigate WordPress' PHP code, you will have the ability to watch how WordPress and it's plethora of available plugins work. Reading code with the debugger can help you understand exactly which lines get execute and when. Peeking into the contents of variables will assist you in tracking down logic errors and gain a better understanding of how the code works.
Last Notes
Despite the initial, less than intuitive project setup process, PhpStorm 8 appears to be loaded with features that cater and lends itself specifically to WordPress developers. Functionality is definitely a major improvement with excellent debugging integration such as floating variable hints and WordPress autocomplete coding capabilities. The variable watch window and code inspectors appear to be more consistent than competing products and stepping through code is quick and easy. PhpStorm 8 matches Netbeans on a feature by feature basis but operates considerably faster. There are a few menu items that overburden the appearance of the user interface and many old features that are of little use. However, part of PhpStorm's cross platform success is merely it's existence; it's certainly better to have robust set of tacked on features (even if seldom used) than to not have them at all. Give it try; it might just be the productivity boost you've been looking for in a dedicated PHP editor.
As the Founder of ServerPress, LLC and creator of DesktopServer, Stephen J. Carnam continues to invent new ways to improve developer Workflow through technology. As a huge Advocate of Open Source Software, he promotes Creativity, Community and Collaboration.
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.
As the Founder of ServerPress, LLC and creator of DesktopServer, Stephen J. Carnam continues to invent new ways to improve developer Workflow through technology. As a huge Advocate of Open Source Software, he promotes Creativity, Community and Collaboration.
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.
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 https://www.jetbrains.com/phpstorm/download/#section=windows 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.
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.
Phpstorm 8.0.3
Step 11: For 30 days free trial, select Evaluate for free rather than Activate and click on Evaluate.
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 502
Step 4: The output of the above program will be-