Search code examples
phpcoding-stylenamespacesnaming-conventions

Is there a well-established naming convention for PHP namespaces?


So far, I've seen many different naming conventions used for PHP namespaces. Some people use PascalCase\Just\Like\For\Classes, some use underscored\lower_case\names, some even use the Java convention for package names: com\domain\project\package.

The question is very simple -- can any of these (or other) conventions be called well-established? Why? Are any of them recommended by authorities like Zend or the developers of well-known PHP frameworks?


Solution

  • A PHP Standards Working Group made up of contributors to many different PHP frameworks and projects came up with the following proposal for appropriate namespace usage:

    https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md