August 29, 2012

Splitting PHP class files for PSR-0 compliance

Have a ton of classes in one file that need to be split up? Check out Matthew Turland’s class splitter script.

Put it in a folder somewhere in your computer, open up a terminal in that location, and then use it like this:

php php-class-splitter.php /path/to/file/with/lotsofclasses.php /path/to/new/class/directory

It is likely that you will end up putting your new split classes in the same location as the original file. If you are going for PSR0 compliance, you will need to add a namespace to each class after.