Forked from Thinkscape/PSR-0-final-proposal.md
Created
February 18, 2013 14:56
Revisions
-
Thinkscape revised this gist
Sep 22, 2011 . 1 changed file with 7 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ # PSR-0 Final Proposal (PHP Standards Working Group) # The following describes the mandatory requirements that must be adhered to for autoloader interoperability. ## Mandatory: ## @@ -11,14 +12,14 @@ The following describes the mandatory requirements that must be adhered to for a * Alphabetic characters in vendor names, namespaces, and class names may be of any combination of lower case and upper case. ## Examples: ## * `\Doctrine\Common\IsolatedClassLoader => /path/to/project/lib/vendor/Doctrine/Common/IsolatedClassLoader.php` * `\Symfony\Core\Request => /path/to/project/lib/vendor/Symfony/Core/Request.php` * `\Zend\Acl => /path/to/project/lib/vendor/Zend/Acl.php` * `\Zend\Mail\Message => /path/to/project/lib/vendor/Zend/Mail/Message.php` ## Underscores in namespaces and class names: ## * `\namespace\package\Class_Name => /path/to/project/lib/vendor/namespace/package/Class/Name.php` * `\namespace\package_name\Class_Name => /path/to/project/lib/vendor/namespace/package_name/Class/Name.php` The standards we set here should be the lowest common denominator for painless autoloader interoperability. You can test that you are following these standards by utilizing this sample SplClassLoader implementation which is able to load PHP 5.3 classes. -
Thinkscape revised this gist
Sep 22, 2011 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,19 +2,19 @@ The following describes the mandatory requirements that must be adhered to for a ## Mandatory: ## * 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"). * Each namespace can have as many sub-namespaces as it wishes. * Each namespace separator is converted to a `DIRECTORY_SEPARATOR` when loading from the file system. * Each "\_" character in the CLASS NAME is converted to a `DIRECTORY_SEPARATOR`. The "\_" character has no special meaning in the namespace. * The fully-qualified namespace and class is suffixed with ".php" when loading from the file system. * Alphabetic characters in vendor names, namespaces, and class names may be of any combination of lower case and upper case. ## Examples: ## * `\Doctrine\Common\IsolatedClassLoader` => /path/to/project/lib/vendor/Doctrine/Common/IsolatedClassLoader.php * `\Symfony\Core\Request` => /path/to/project/lib/vendor/Symfony/Core/Request.php * `\Zend\Acl` => /path/to/project/lib/vendor/Zend/Acl.php * `\Zend\Mail\Message` => /path/to/project/lib/vendor/Zend/Mail/Message.php ## Underscores in namespaces and class names: ## * \namespace\package\Class_Name => /path/to/project/lib/vendor/namespace/package/Class/Name.php -
Thinkscape revised this gist
Sep 22, 2011 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,11 +2,11 @@ The following describes the mandatory requirements that must be adhered to for a ## Mandatory: ## * 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"). * Each namespace can have as many sub-namespaces as it wishes. * Each namespace separator is converted to a DIRECTORY_SEPARATOR when loading from the file system. * Each "\_" character in the CLASS NAME is converted to a DIRECTORY_SEPARATOR. The "\_" character has no special meaning in the namespace. * The fully-qualified namespace and class is suffixed with ".php" when loading from the file system. * Alphabetic characters in vendor names, namespaces, and class names may be of any combination of lower case and upper case. -
Thinkscape revised this gist
Sep 22, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ The following describes the mandatory requirements that must be adhered to for a ## Mandatory: ## * 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"). * Each namespace can have as many sub-namespaces as it wishes. * Each namespace separator is converted to a DIRECTORY_SEPARATOR when loading from the file system. -
Thinkscape created this gist
Sep 22, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,59 @@ The following describes the mandatory requirements that must be adhered to for autoloader interoperability. ## Mandatory: ## * 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"). * Each namespace can have as many sub-namespaces as it wishes. * Each namespace separator is converted to a DIRECTORY_SEPARATOR when loading from the file system. * Each "_" character in the CLASS NAME is converted to a DIRECTORY_SEPARATOR. The "_" character has no special meaning in the namespace. * The fully-qualified namespace and class is suffixed with ".php" when loading from the file system. * Alphabetic characters in vendor names, namespaces, and class names may be of any combination of lower case and upper case. ## Examples: ## * \Doctrine\Common\IsolatedClassLoader => /path/to/project/lib/vendor/Doctrine/Common/IsolatedClassLoader.php * \Symfony\Core\Request => /path/to/project/lib/vendor/Symfony/Core/Request.php * \Zend\Acl => /path/to/project/lib/vendor/Zend/Acl.php * \Zend\Mail\Message => /path/to/project/lib/vendor/Zend/Mail/Message.php ## Underscores in namespaces and class names: ## * \namespace\package\Class_Name => /path/to/project/lib/vendor/namespace/package/Class/Name.php * \namespace\package_name\Class_Name => /path/to/project/lib/vendor/namespace/package_name/Class/Name.php The standards we set here should be the lowest common denominator for painless autoloader interoperability. You can test that you are following these standards by utilizing this sample SplClassLoader implementation which is able to load PHP 5.3 classes. ## Example Implementation ## Below is an example function to simply demonstrate how the above proposed standards are autoloaded. ````php <?php function autoload($className) { $className = ltrim($className, '\\'); $fileName = ''; $namespace = ''; if ($lastNsPos = strripos($className, '\\')) { $namespace = substr($className, 0, $lastNsPos); $className = substr($className, $lastNsPos + 1); $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; } $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; require $fileName; } ```` . ## SplClassLoader Implementation ## The following gist is a sample SplClassLoader implementation that can load your classes if you follow the autoloader interoperability standards proposed above. It is the current recommended way to load PHP 5.3 classes that follow these standards. http://gist.github.com/221634 ## Source ## This document has been fetched from [google page cache](http://webcache.googleusercontent.com/search?q=cache:XOHGigFVti8J:groups.google.com/group/php-standards/web/psr-0-final-proposal+https://groups.google.com/group/php-standards/web/psr-0-final-proposal&cd=1&hl=en&ct=clnk&gl=pl&lr=lang_pl|lang_en) and transformed to markdown by me. The original (broken) url is http://groups.google.com/group/php-standards/web/psr-0-final-proposal