The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.
- Introduction
The goal for this specification is to extend PSR-0 and to provide an alternative option for applications to determine the location of a file resource on a medium as supported by PHP, when a fully-qualified class name is provided.
- Scope
This specification is partly backwards incompatible with PSR-0. Where a conflict occurs the rules in this specification precede, or override, the rules in PSR-0.
- Specification
- The
_
character has no special meaning in class names. - For a collection of one or more classes a namespace prefix MUST be documented.
- The documented namespace prefix MUST be a valid namespace for each class in the collection.
- The portion of the fully-qualified class name following the namespace prefix must be considered the fully-qualified class name for the purpose of transformation into a filename.
- A conforming autoloader MUST NOT interfere with other autoloaders, and as such it MUST NOT throw exceptions, MUST NOT raise errors of any level, and SHOULD NOT return a value.
- Examples
- Given a namespace prefix
\Doctrine\Common
and a fully-qualified class name\Doctrine\Common\IsolatedClassLoader
, the resulting filename would beIsolatedClassLoader.php
. - Given a namespace prefix
\Doctrine
and a fully-qualified class name\Doctrine\Common\IsolatedClassLoader
, the resulting filename would beCommon/IsolatedClassLoader.php
. - Given a namespace prefix
\Symfony\Component\HttpFoundation
and a fully-qualified class name\Symfony\Component\HttpFoundation\Request
, the resulting filename would beRequest.php
. - Given a namespace prefix
\Symfony
and a fully-qualified class name\Symfony\Component\HttpFoundation\Request
, the resulting filename would beComponent/HttpFoundation/Request.php
. - Given a namespace prefix
\Zend
and a fully-qualified class name\Zend\Acl
, the resulting filename would beAcl.php
. - Given a namespace prefix
\Acme\My_Project
and a fully-qualified class name\Acme\My_Project\Some_module\some_class
, the resulting filename would beSome_module/some_class.php
.
While I am a fan of terseness and less-is-more, what I see here is a variation on the same problem that @philsturgeon pulled the second vote for. That is, if you don't already understand the rules, just reading the rules won't help. The only thing that does make clear what's happening is the examples, and apparently examples are bad to have in the spec.
We have to recall that the one thing that made PSR-0 acceptable to the original members was the code implementation written by Matthew Weier O'Phinney. The document was bogged down in arguments like we have now, until MWOP wrote some code, and everyone agreed "yes, this is what we mean."