HomePHP Using Aliases and the Autoload Function with Namespaces in PHP 5
Using Aliases and the Autoload Function with Namespaces in PHP 5
Namespaces are an elegant approach to solving naming conflicts between the classes that are used by a PHP application. Indeed, itís pretty common to suffer this problem during the development of a project thatís been charged to several programmers, and also when working with third-party libraries. This four-part series of articles, of which this is the last, shows you how to handle namespaces.
Hopefully, the introduction of PHP 5.3 will contribute to fixing these issues, since it will incorporate support for namespaces. In the meantime, as you wait for its release, you may want to take a close look at this group of articles, which will walk you through the basics of using namespaces with PHP 5 by way of a hands-on approach.
And speaking of hands-on approaches, youíll possibly recall that in the previous article of this series, I explained by means of distinct practical examples how to utilize the ďuseĒ PHP keyword to tie a couple of sample classes to different namespaces. Of course, one of the most important benefits in using this reserved word is that it requires a shorter syntax for declaring and utilizing a certain namespace. This approach appeals to many programmers.
It's worth noting, though, that PHP 5.3 will let you use yet another notation that can be quite helpful when it comes to declaring namespaces in a more intuitive way. In this specific case, Iím talking about the ability to work with aliases, that is, meaningful words that can be directly linked to a given namespace.
If youíre interested in learning how to use aliases when working with namespaces, in this article Iíll be taking a close look at this topic, so you can learn quickly how to put this feature to work for you.
Now, itís time to get rid of the preliminaries, and start discovering the real power in using namespace aliases with PHP 5. Letís get going!