BreadcrumbHomeResourcesBlog Optimizing PHP Web Apps By Integrating ZendPHP With PhpStorm October 15, 2024 Optimizing PHP Web Apps by Integrating ZendPHP With PhpStormPHP DevelopmentDebuggingBy Adam HessMany PHP teams choose to utilize an Integrated Development Environment (IDE) such as PhpStorm to improve the performance of their mission-critical applications. However, despite PhpStorm's popularity, it is far from the only optimization tool available, and understanding your options is critical for managing successful web applications.In this blog, I provide an overview about why PHP IDEs are often chosen by developer teams. I then take you through a step-by-step guide for how to integrate ZendPHP with PhpStorm on Windows. Finally, I explore how the ZendHQ extension for ZendPHP can be used as a PhpStorm alternative for optimizing PHP apps.Table of ContentsPHP IDE: An Overview of ZendPHP and PhpStormHow to Integrate PhpStorm and Zend on WindowsZendHQ: An Alternative Method for Optimizing PHPFinal ThoughtsTable of Contents1 - PHP IDE: An Overview of ZendPHP and PhpStorm2 - How to Integrate PhpStorm and Zend on Windows3 - ZendHQ: An Alternative Method for Optimizing PHP4 - Final ThoughtsBack to topPHP IDE: An Overview of ZendPHP and PhpStormIf your developer team has opted to use an IDE for developing your PHP application, there are a number of IDEs one can choose from. Some will be lightweight, and others packed with useful features. Over time however, PhpStorm has become the go-to IDE for PHP development, so we will be taking a look at how to use it with ZendPHP.What is ZendPHP?ZendPHP is a set of PHP runtimes that deliver support, security, and tooling options for PHP web applications.Managing a PHP environment can be involved, requiring developers to deal with integrations, configuration issues, security concerns, and general upgrading. ZendPHP alleviates these issues by providing package repositories with installable PHP binaries for several different operating systems. Additionally, ZendPHP comes with long term support that includes security updates after a PHP version goes end of life and no longer receives community support.Learn More About ZendPHP Runtimes >>What is PhpStorm?PhpStorm is a commercial PHP IDE developed by JetBrains. It is compatible with PHP, HTML, and JavaScript, providing real-time code completion and other features.Many PHP applications involve languages and technologies beyond just PHP. PhpStorm, and IDEs like it, can help simplify web development stacks. While there have been many other IDEs, such as Eclipse or NetBeans, the PHP community has generally consolidated around PhpStorm.Why Use an IDE for PHP?At their cores, IDEs are text editors for writing and managing a code base. They provide tools to aid in project development, ranging from template generation, repository integration, debugging features, code highlighting, and more.There can be a preference between using a lightweight IDE (like notepad++) with minimal tools, and a more complete one akin to PhpStorm, which can provide a number of tools to aid in development. The choice comes down to user preference and comfort level. While a more complete IDE can feel overwhelming at first with so many options, learning to use the tools it provides will ultimately speed your project development.To demonstrate how to use IDEs for PHP, I will now walk through how to integrate PhpStorm and ZendPHP on Windows in a typical development scenario. Back to topHow to Integrate PhpStorm and Zend on WindowsIDEs for PHP, such as PhpStorm, are a viable option for web developers looking to reduce application development lifecycles, troubleshoot code, and optimize their PHP web applications. However, to take full advantage of IDE features with ZendPHP, you must first ensure that your PHP runtimes have been correctly installed, configured, and verified. In this tutorial, we'll go through the following steps for using PhpStorm with Zend runtimes:Installing ZendPHP on WindowsConfiguring XdebugIntegrating ZendPHP With PhpStormTry ZendPHP Free for 30 DaysThis tutorial requires ZendPHP credentials. If you are not a current ZendPHP customer, we offer a 30-day free trial with no commitment required.ZendPHP Trial Details Learn More About ZendPHPStep One: Install ZendPHP on Windows Using a Microsoft Software Installer (MSI) PackageZendPHP currently supports Windows 10 or 11, and Windows Server 2016 or 2019, and installation is rather straightforward with the associated MSI. Additional details about the process and more information for each step can be found in the associated documentation.Select the Relevant MSI InstallerAs of this blog's publication, ZendPHP supports PHP versions from PHP 7.2 through PHP 8.3. Select the MSI installer for your preferred version using the documentation link above. Alternatively, you may include them in the user such as this:https://USERNAME:PASSWORD@repos.zend.com/zendphp/windows/latest/zendphp-8.3-latest-nts-x64.msi Install ZendPHPThere are two ways to install ZendPHP: through the ZendHQ User Interface, or via the command line. The recommended way is to open the installer in Windows Explorer and follow the instructions in the installer window. Command line installation is a more complicated process, and it is generally recommended for more experienced users. Additional details about command line installation can be found in the Zend documentation.Validate the ZendPHP InstallationAfter installation, it is a good practice to validate the installation. As a testing method, the default Apache configuration creates a sample page at:http://ip_address/php<major version>.<minor version>An example would be: http://127.0.0.1/php8.3Run the appropriate URL to ensure your web server is running. Lastly, check in the Windows Start Menu to ensure that shortcuts have been created.A Note on Installing ZendPHP on WindowsPlease note that the ZendPHP installer does not automatically configure your web server for secure sockets layers (SSL). Information on setting up SSL can be found here.Step Two: Configure XdebugThe next step in integrating PhpStorm and Zend runtimes requires configuring Xdebug to match your system requirements. Begin by ensuring that you have downloaded and installed XDebug, instructions found here. Once you have completed installation, you can integrate Xdebug with the PHP engine.Edit in the php.ini FileNext, we will be editing the php.ini file. To locate this, go to your default page for your web server as discussed in the section above, or by generating a phpinfo(). The field for: Loaded Configuration File will state where your php.ini file can be located. Open this in an editor.Ensure Xdebug Will Not Be BlockedYou will want to find and comment out the following two fields, as these tools can block Xdebug:zend_extension=<path_to_zend_debugger> zend_extension=<path_to_zend_optimizer>You will also need to enable Xdebug. If there is not an Xdebug section to update, create a new one and enter:[xdebug] zend_extension="<path to xdebug extension>" xdebug.mode=debug xdebug.client_host=127.0.0.1 xdebug.client_port="<the port (9003 by default) to which Xdebug connects>"Lastly, save and close the php.ini file.Verify Xdebug's ConfigurationNow we will want to verify that Xdebug is configured. This can be done one of two ways.For the first method, you can verify configuration by typing php-version in the command line. You should see your Xdebug version mentioned after the Zend Engine. For the second method, you can load your phpinfo() page, and it should now have an Xdebug section. Step Three: Integrate ZendPHP With PhpStormOnce ZendPHP and Xdebug have both been successfully installed, configured, and verified, we can move on to the final steps for integrating PhpStorm IDE for PHP with ZendPHP.Select PHP OptionsIn PhpStorm, open your settings with Alt+Crtl+S, and select the PHP option on the left. There will be a field for CLI interpreters with an ellipsis after it. Click the ellipsis. This will show all the PHP installations that PhpStorm sees. If no debugger is installed, there will be a note on the left that states, "debugger not installed."Find additional troubleshooting steps here.Define Xdebug BehaviorNext we’ll want to define Xdebug behavior. In the settings (Alt+Ctrl+S), select DEBUG under the PHP heading on the left. You will want to set the debug port. Note that this must match the same port listed in your php.ini file for Xdebug. The default for Xdebug 3 is port 9003. To ensure PhpStorm will accept any incoming connections from Xdebug via that port, select the “can accept external connections” checkbox.There will be additional checkboxes for various debugging options. Further details can be found here.Define How PhpStorm Treats ConnectionsLastly in the “External Connections” area, you may want to define how PhpStorm will treat connections received from hosts and ports that are not registered as deployment server configs. There will be three fields. The first field will ask if you want to ignore connections through unregistered configurations. Note that PhpStorm does not attempt to create a deployment server config automatically. The second field will have the debugger stop immediately when a connection between it and PhpStorm is established, instead of running until a break point is reached. The third field will allow you to limit the number of external connections that can occur simultaneously.Back to topZendHQ: An Alternative Method for Optimizing PHPWhile IDEs for PHP (like PhpStorm) and step debuggers (such as Xdebug) are commonly utilized for optimizing PHP web applications, they are not the only options available for developers. For instance, ZendPHP users can access ZendHQ, an extension that provides advanced observability and orchestration tooling for ZendPHP runtimes.How ZendHQ WorksZendHQ is an intermediary layer between ZendPHP and your application storage, webhooks, and graphical interface. Operating as a standalone node in your application architecture, ZendHQ collects information from all ZendPHP nodes in your production system. It can then be used to integrate with other systems, defer tasks to microservices, or pass monitoring events to other systems via webhooks.Z-Ray for Debugging and Optimizing PHPUsing Z-Ray, a tool that provides application-level insight into requests to your API, ZendHQ makes it easy to identify, understand, and eliminate complex issues. Z-Ray works to identify the root cause of an issue, and every request includes a full stack track of function calls from within your application. This report also includes information surrounding timing and memory usage for those calls, allowing you to prioritize each by need.Additionally, Z-Ray is extensible, and a number of plugins are included by default. These plugins trigger under pre-set and specific conditions, allowing your team to identify issues and work flows that lead to errors, optimizing PHP applications and processes with a single observability tool.Learn More About Debugging PHP With ZendHQ >>Back to topFinal ThoughtsWhether you choose to work with an IDE, ZendHQ, or a different tool entirely, optimizing your PHP allows you to identify and address issues before they become big problems. While each option has it's own individual merits, the best choice for your organization will ultimately come down to your application, team, and resources.Make Our PHP Experts Your PHP ExpertsZend professional services are designed to optimize the performance of your PHP applications. Explore our services, or contact us to learn more.Professional Services Talk to an ExpertAdditional ResourcesOn-Demand Webinar - PHP Observability and Orchestration With ZendHQCase Study - Bark.com Modernizes Mission-Critical PHP Application With Professional Services From ZendBlog - PHP Debugging: Go Beyond Step Debuggers With ZendHQBlog - PHP Errors: How to Find and Fix PHP Errors in ProductionBlog - PHP Code Tracing With ZendHQBlog - Debugging PHP Segmentation FaultsBack to top
Adam Hess Technical Support Engineer, Zend by Perforce Adam Hess is a full-time technical support engineer for Zend by Perforce. He has many years of experience developing with php (v4 through v8), and a variety of php frameworks like Zend Framework, Cake, and Symphony. He has also worked with a variety of other programming languages and frameworks - including Python, Django, ViewJs, and other Javascript.