Example of good PHP namespace usage?
| From: | D. Dante Lorenso | Date: | Fri, 19 Mar 2010 07:05:47 +0000 |
| Subject: | Example of good PHP namespace usage? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-302994@lists.php.net to get a copy of this message | ||
All,
I want to start using PHP namespaces for my projects. Currently, I name my classes similar to how Zend Framework names theirs and I end up with classes like:
LS_Util_String
I'm thinking that if I converted this to namespaces, the classes would be named like:
LS\Util\String
I'd like to look at an example of an open source project that has already adopted namespaces as "the way to do it" and would be a good best practices case for how I should go about setting up my library namespaces.
I have been playing with concepts of using a Java-like naming convention for classes and have created my own namespace like:
com\larkspark\util\StringAnd here I was thinking that packages would be lowercase and classes would be camelcase with initial caps. I'm getting ready to build a new project and wanted to do it in the future-forward style while removing legacy classes and refactoring everything to use namespaces. Any examples out there? Everything I find from searching Google is novice intro to PHP namespaces blogs, but nothing concrete. Also since namespaces are relatively new, I see a lot of misleading guides where they are using "::" instead of "\" to separate class name parts. What does this list recommend? Dante