Is this the correct way to use PSR-0/namespaces?

PSR-0 states:

  • A fully-qualified namespace and class must have the following structure \<Vendor Name>\(<Namespace>\)*<Class Name>
  • Each namespace must have a top-level namespace (“Vendor Name”).

Let’s the vendor is AcmePHP and they make a library called AcmeLib. So in the root of where your classes load you’d have:


Then the library has packages such as Form, Database, File. So these would be:


Form may have a sub-package called Validation:


Is that correct use of PSR-0?

Pretty much though I question why you would tie Validation specifically to Forms. But that is a design issue and not a namespace issue.

Pull down the Symfony framework with:
composer create-project symfony/framework-standard-edition path/ “2.5.*”
composer install

It has dozens of examples.

And once you get your head around psr-0, take a look at psr-4 which, while using the same namespace standard, can often cut several folder levels from your source tree.

That was just an arbitrary example but well spotted! :slight_smile:

So the idea then is really you have at least two namespace levels, the first being the vendor, and then you can break it down as you see fit after that?

I have looked as PSR-4 but for what I am currently doing PSR-0 on its own is fine as what I am working with is relatively simple.