drquincy — 2014-07-03T12:32:42-04:00 — #1
- 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?
ahundiak — 2014-07-03T12:45:08-04:00 — #2
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.*"
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.
drquincy — 2014-07-03T12:55:58-04:00 — #3
That was just an arbitrary example but well spotted!
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.