Home arrow PHP arrow 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.

TABLE OF CONTENTS:
  1. Using Aliases and the Autoload Function with Namespaces in PHP 5
  2. Review: the use keyword
  3. Utilizing namespace aliases
  4. Autoloading classes and working with custom functions
By: Alejandro Gervasio
Rating: starstarstarstarstar / 3
December 03, 2008

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

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!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: