Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

php[architect]:
Generating an Autoloader for a Legacy PHP Codebase
Sep 07, 2017 @ 14:11:22

The php[architect] site has posted a new tutorial from editor Oscar Merida showing you how to create an autoloader for a legacy codebase using one of three options.

If you’ve inherited a legacy code base, you may find it does not use an autoloader and has an idiosyncratic directory and file hierarchy for its Classes, Interfaces or Traits. Worse yet, it might not use name spaces consistently or at all. So you can’t use a posting on Twitter. [...] In this post, I’ll detail the three solutions I found: using Composer’s classmap autoloader, Symfony classmap generator (deprecated), or Zend Framework’s ClassFileLocator.

He then goes through each of the tools mentioned above and shows how to implement them to locate class files and auto-generate the autoloader files. They each have slightly different methods of getting the class files from the current code but they all end up with basically the same result: a classmap (set of relations between classes and the files they live in).

tagged: autoloader legacy codebase tutorial composer symfony3 zendframework

Link: https://www.phparch.com/2017/09/generating-autoloader-legacy-php-codebase/


Trending Topics: