20 Useful PHP Testing, Debugging and Optimization Tools

PHP is most famous open source server-side scripting language that powers more than 250 millions of websites. It has detailed documentation, plenty of ready-to-use scripts, well supported frameworks and a huge community. And yes, the most important thing, it is much easier to get started with PHP than any other scripting language.

We present a complete list of interesting tools that can help you properly analyze, test, debug and optimize your PHP application. Along with saving time, you can create more maintainable code with less security issues and better performance.

20. Whoops

Whoops is an error handler framework that comes with a nice interface for debugging your web projects in a less painful way. It provides a flexible, stack-based error handling, stand-alone library with no required dependencies, and simple API for dealing with exceptions, trace frame and their data.

19. Debug Bar

Debug bar can display profiling data from any par of your app. It has a built-in data collector for standard PHP features and popular projects. It features generic debug bar with no dependencies, handles AJAX request and client side bar is completely coded in JavaScript.

18. Pinba

Pinba is a MySQL storage engine designed to help developers to monitor performance of PHP scripts and locate bottlenecks in realtime. It gathers and processes data send over UDP and displays statistics in a nice human-readable format. In addition, it provides read-only interface to the raw data in create more sophisticated reports and stats.




PHPLOC is a tool for measuring the size of your project in lines of code (LOC), number of classes, number of files and so on. It can walk through Git revisions, and generate retroactive reports in CSV format.
All you need to do is download the PHP archive that has all required dependencies of PHPLOC bundled in a single file.

16. PHP Profile Class

PHP Profile Class

PHP Profile Class allows you to find bottleneck in your application code and discover areas that would benefit from optimization. The tool calculates the total time to render a page, and records the execution time of the method given.

15. Selenium


Selenium is automated testing framework that allows you to write user acceptance tests to examine the entire application. It has its own WebDriver API and built-in grid capabilities.
With Selenium you can create robust, browser-based regression automation suites, create quick bug reproduction scripts, and scale and distribute scripts across many environments.

14. Peridot


Peridot is a lightweight, extensible and behavior-driven development testing framework for PHP. The event driven architecture allows you to easily customize the framework via plugins and reporters. It uses describe-it syntax to easily describe how your application code should behave in a language that make sense.

13. vfsStream


vfsStream can be used with any unit testing framework, like SimpleTest or PHPUnit. It’s a PHP stream wrapper for virtual file system that may be helpful in unit tests to mock the real file system.
As shown in the example, the test case is much smaller and, with vfsStream, you can control what the file system environment will look like, as it is not influenced by any other operation that might take place while executing the test.

12. Storyplayer


Storyplayer is a full-stack framework that allows you to write end-to-end tests for your entire platform and run them against staging, QA and production alike. You can write tests for each service in your platform and store those tests alongside your code and unit tests. Storyplayer follows the TDD testing technique and supports creating and destroying test environments on demand. All tests are written in PHP.

11. PHP Mess Detector

PHP Mess Detector

PHP Mess Detector is user friendly and easy to configure frontend for the raw metrics measured by PHP_Depend. It looks for messy code, potential bugs, unused expression, overcomplicated methods, suboptimal code and so on. There are limited predefined rules or you can write your own to detect possible errors within the analyzed source code.

10. Xdebug


The Xdebug PHP extension provides debugging and profiling capabilities. It uses DBGp protocol to extract information about stack, function traces in error messages, memory allocation and protection for infinite recursions. Moreover, it provides code coverage analysis and the ability to debug your source code interactively with a debugger front-end.

9. SimpleTest


SimpleTest is a PHP unit test and web test framework that uses test-driven development style. It supports SSL, frames, forms, proxies and basic authentication.
SimpleTest aims to be a complete PHP developer test solution and it is easy to use and extend. It includes all of the typical functions you would expect from the PHPUnit and JUnit ports, and includes mock objects.

8. Kahlan


Kahlan is full-featured BDD testing framework that uses describe-it syntax to describe how your code should behave. It allows to stub or monkey patch your code directly like in JavaScript without PECL-extentions. It comes with a variety of built-in reporters and exporters.

Kahlan has a small code base – it is 10 times smaller than PHPUnit. It works on KISS (Keep It Simple, Stupid) principle. The tool is extensible and supports customizable workflow.

7. Cucumber


Cucumber is a behavior-driven development tool that allows you to write tests in plain English and execute them in conjunction with third party tools (like Selenium) to execute the tests within a browser. It is primarily written for testing Ruby on Rails applications, but can also be used with numerous mainstream programming languages, including PHP, Python and Java.

6. PHP CodeSniffer

PHP CodeSniffer

CodeSniffer sniffs through the source code and detects violations in syntax or defined set of coding standards. Along with PHP, it works for JavaScript and CSS files.
It’s a combination of two PHP scripts – the first one is phpcs that tokenizes CSS, PHP and JavaScript to detect violations. And the second is phpcbf that automatically corrects the violation.

5. Atoum


Atoum is a simple, modern and intuitive unit testing framework designed to simplify test development environment. It features a fluent interface that allows you to write unit tests in a fashion close to natural language. It enables high level of security during test execution by isolating each test method in its own PHP process.

Atoum runs tests in a parallelized environment in order to make suite run as fast as possible by taking advantage of today’s multi-core CPUs. It can also generate unit test execution reports in the Xunit format that makes it compatible with continuous integration tools.

4. PHPSpec


PHPSpec helps you write clean and working PHP code using behavior driven development (BDD). The technique is to first use PHPSpec to describe the behavior of an object you are about to write, then you write just enough code to meet the requirement and specification, and finally you refactor this code. The concept and feature of this tool will keep your focus on the “right” things.

3. Behat


Behat is an open-source behavior-driven PHP testing framework. With Behat, you write human-readable stories that describe the behavior of your application. These stories can further be tested against your application. It creates a context object for each scenario and executes all scenario steps within the same object. Also, it comes with a powerful console utility (with a wide variety of options) responsible for running Behat tests.

Read: What’s New in PHP 7: Things You Should Know

2. PHPUnit


PHPUnit is widely used programmer-oriented testing framework that can be used via command line. It is an instance of the xUnit architecture for unit testing framework. It is packed with handy TestCase class that you can extend according to your requirements. Moreover, you can conduct test-driven development and use pre-written assertion methods.

1. Codeception


Codeception isn’t just limited to unit test. Here you can conduct acceptance, functional and API testing. The framework is much more like PHPUnit on steroids – everything you need for testing is built-in. You can enable and configure different modules according to your development needs.

Read: 35+ Amazing PHP Libraries for Programmers and Developers

In order to bring automation testing framework and development framework together, Codeception is integrated with many other PHP development frameworks, including Yii, Symfony2, Phalcon, Zend Framework and Laravel.

Written by
Varun Kumar

I am a professional technology and business research analyst with more than a decade of experience in the field. My main areas of expertise include software technologies, business strategies, competitive analysis, and staying up-to-date with market trends.

I hold a Master's degree in computer science from GGSIPU University. If you'd like to learn more about my latest projects and insights, please don't hesitate to reach out to me via email at [email protected].

View all articles
Leave a reply