The TutsPlus.com site has posted the fourth part of their series covering the use of namespacing and autoloading in WordPress plugins. In this latest tutorial they take everything they've shared (and made) previously and put it all together into a cohesive whole plugin.
At this point, we've laid the foundation for our plugin, written the plugin, and defined and explored namespaces and autoloaders. All that's left is to apply what we've learned.
So in this tutorial, we're going to put all of the pieces together. Specifically, we're going to revisit the source code of our plugin, namespace all relevant classes, and write an autoloader so that we can remove all of our include statements.
He starts off talking about namespacing and how it relates to directory structure and the code you'll need for each of the plugin files for put them in the correct namespace. With just these in place, however, errors are thrown. This requires the setup of a custom autoloader and PHP's own spl_autoload_register handling. He includes the code for the autoloader, taking in the class name and splitting it up to locate the correct directory, making it easier to replace the loading of all plugin scripts.