Assertions for CLI commands

By Fabien Potencier, on Oct 08, 2015

A few weeks ago, we introduced assertions for HTTP requests. HTTP Assertions are a great way to set up your own expectations about code performance but PHP is not limited to only serve HTTP requests anymore. Nowadays, most projects also use PHP for scripts that need to be run on the command line. That’s why we are happy to announce that CLI Assertions are also supported.

CLI Assertions work the same way as their HTTP counterparts, the only difference being how Blackfire decides which assertions to run for the current script. For HTTP requests, assertions are run when the URL matches the path regex; for CLI scripts, Blackfire uses the command regex:

Now, whenever you profile the cleanup.php script (via blackfire run php cleanup.php for instance), the first test will run. CLI assertions can use all features available for HTTP assertions, the same variables are available and you even define assertions for profile comparisons. Read more about this feature on the official documentation.

Happy profiling!

 

Fabien Potencier

Fabien Potencier is the CEO and founder of Blackfire.io. He founded the Symfony project in 2004 as he constantly looked for better ways to build websites. Fabien is also the creator of several other Open-Source projects, a writer, a blogger, a speaker at international conferences, and the happy father of two wonderful kids.