It looks like you're using it right, but you might not have a need for it.
Namespacing allows you to use function and symbol names without worrying about whether a third-party library declares the same thing (which would cause a fatal error in PHP). You can take comfort in knowing that, because you've namespaced everything, there's no chance for collision.
But if you're in a position where you're going to know and account for all possible symbols, you're not going to get a whole lot of value from namespaces. Edit: And as G3D mentions in the comments, your specific use case is covered by PEAR's naming conventions.
However, relying on prefixes might not work as you'd expect if you start introducing a lot of unknowns.
This comes up in Drupal: let's say you've created a module that's named views. Well, Drupal provides a hook system, so you can do things like implement the function
hook_foo() by replacing
hook with your module's name.
So now you have an implementation of a hook named
views_foo(). That's all well and fine as long as you didn't need an internal function named
But let's say there's a new module that extends your module and names itself views_awesome. If
views_awesome wants to implement
hook_foo(), it'd create a new function named
Ah, but I didn't tell you about another hook already defined:
hook_awesome_foo(). So, without namespacing, you have a collision:
views_awesome_foo() can refer to
view_awesome's implementation of
views's implementation of
In this scenario, namespacing is really helpful. Instead of prefixing hook implementations, you can do:
and avoid any ambiguity.