So you're a l337 php coder. So you're using classes to make things awesome... and you are also tired of including every single file you need. You don't want to, but you end up loading every bit of your application with a huge list of includes, even if you don't need all of it.

In comes the PHP class autoloader magic function.

__autoload($className) { // Your awesome code here require_once($classPath);}

As you might expect there are many ways to auto load classes. lifeBLUE has their preferred method. However, there are times that you want to have more than one class autoloader for different situations. Our current application actually has several ways for loading classes in. This presents a problem, as the autoloader can become a complicated mess. Thankfully there is a nice little function PHP provides us that makes these problems go away.

// Awesome PHP autoloading register functionspl_autoload_register("FunctionNameOne");// Calling a static class functionspl_autoload_register(array("ClassName", "FunctionNameTwo"));

Once you have registered your functions, you can write them to include your class in whatever method you choose. For more reading check out the PHP site for the documentation.

Using this allows you to have more than one autoloader present in your application. It also allows you to have your own autoloader function co-exist nicely with autoload functions from libraries you get from third parties.

Happy including!