Intro to Brain

Brain is a PHP framework utilizing Composer, Pimple, and partially derived from CodeIgniter (only 6 classes). Swiftmailer, DOMPDF, phpseclib, Doctrine DBAL, and FirePHP are also integrated into Brain by default. The inspiration behind Brain was initially a desire to abandon CodeIgniter, mainly due to objections in the licensing of the 3.x branch. Much work went into converting CodeIgniter classes to use outside of their framework, but as Brain has been refined, these classes have largely been phased out, and in many cases changed in such a way that they no longer represent the original classes.

Composer

While Composer handles bringing in external packages and dependencies, one of the handier features of Composer is it’s built in PSR-0 and PSR-4 autoloaders. Brain utilizes the PSR-4 autoloader for all classes.

Pimple

Pimple, quite frankly, is at the heart of what makes Brain work. In CodeIgniter there is a “super object”, and Pimple is similar in that it defines or references objects, and the references can be called or passed around so the objects are available on demand. One real benefit to using Pimple is that objects don’t have to be instantiated to be defined, so until they are called they aren’t actually loaded. That said, since Brain uses Pimple as a DI container instead of a service locator, the objects are instantiated because they have to be to be injected.

In Brain, Pimple is the parent of the Container class, which is “the app”.

Static Access

Nearly all of the classes that are defined in the container have a static access counterpart. By making most classes and their methods available via static access, it’s up to the developer to choose how to use the class. I figured, why get all religious about what’s right and wrong? Instead, write code that works for you.

The Cutting Edge

Brain strives to stay at the cutting edge. Updates will not usually consider compatibility with PHP versions much older than the current stable version.