Chapter 3. Implement an Autoloader

In this step, we will set up automatic class loading. After this, when we need a class file, we will not need an include or require statement to load it for us. You should review the PHP documentation on autoloaders before continuing – http://www.php.net/manual/en/language.oop5.autoload.php.

PSR-0

There are many different autoloader recommendations in PHP land. The one we will be using to modernize our legacy application is based on something called PSR-0.

PSR-0 is a PHP Framework Interoperability Group recommendation for structuring your class files. The recommendation rises out of a long history of projects using the "class-to-file" naming convention from the days of PHP 4. Originating with Horde and PEAR, the ...

Get Modernizing Legacy Applications in PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.