New Tutorial: Your First PHP Prefixed Project

Your First PHP Prefixed Project

Following the launch of  PHP-Prefixer, we’re excited to share the first tutorial “Getting Started”!

If you develop PHP projects with Composer, you’ll feel at home with this new guide. It walks you through the fundamentals of Composer project development by creating a simple project step-by-step. After completing the tutorial, you’ll prefix the “Getting Started” project to create the prefixed project’s codebase.

The sample project calls the Monolog library to log a warning message in a log file:

$log = new \Monolog\Logger('name');
$log->pushHandler(new \Monolog\Handler\StreamHandler('app.log', \Monolog\Logger::WARNING));

After the PHP-Prefixer service does its magic, the source code and all the associated files are prefixed in this way:

$log = new \PPP\Monolog\Logger('name');
$log->pushHandler(new \PPP\Monolog\Handler\StreamHandler('app.log', \PPP\Monolog\Logger::WARNING));

Find the source code of the project  in this repository:

Find the result of the prefixing process of the project  in this repository:

What We’ll Build

The “Getting Started” project includes the configuration of the prefixer to process the project files and the Monolog library.


  • The original code of a project,
  • The composer.json  configuration to apply the prefix PPP with the PHP-Prefixer processing service,
  • The produced source code where the PPP has been processed.

Simple and Stable

In January 2019, when we started to prefix our PHP code, we faced many roadblocks, but it was worth the effort because; our code worked. Our idea had turned into reality! 

After almost two years of development, we have created a rule-based expert system and service for  simplifying the continuous operation of the PHP prefixer engine.

For example, in the “Getting Started” guide, the same test code demonstrates how the sample routine works fine. Additionally, the prefixed Monolog library is tested with the original test cases to confirm that it meets the original requirements.

~/vendor_prefixed/monolog/monolog$ phpunit
PHPUnit 5.7.27 by Sebastian Bergmann and contributors.

................................................................. 65 / 97 ( 67%)
................................                                  97 / 97 (100%)

Time: 116 ms, Memory: 6.00MB

Bottom line: If you’re looking for a practical, hands-on tutorial to prefix PHP source code, look no further.

Try the Tutorial

Do you want to learn PHP-Prefixer? Follow the tutorial here and build your first prefixed project!

Photo by Luca Bravo on Unsplash

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.