NYCPHP Meetup

NYPHP.org

[nycphp-talk] Namespaces

John Campbell jcampbell1 at gmail.com
Fri Jan 11 12:08:05 EST 2008


Namespaces are supposed to be analogous to folders in the file system.
 Folders are how we prevent file name collisions, and namespaces are
how we prevent function/classname collisions.  If you have a bunch of
files that might have the same names as an existing file, then you
just create a new folder.  If you are importing code that may have
function/class collision, then you import it into a different
namespace.  Unfortunately I think the php devs don't think of
namespaces in the same way, and it looks like the 5.3 namespace
implementation will lack the ability to rename the namespace and
relies on everyone using a unique namespace.  The domain convention is
okay, but I would much rather be able to do something like:

include 'dkSuperClass.php' into namespace 'foo'

It looks like the php devs are going the Java route, which ain't great
because it relies on every library being changed which will never
happen for compatibility reasons.

I would much rather have a tool that lets me solve collisions today
than a tool that requires libraries to be rewritten and agreement on a
naming convention in order for it to work.

</rant>

Regards,
John Campbell



More information about the talk mailing list