As the size of your PHP code library increases, there is increased risk of accidentally re-defining a function or class name that has been declared before. The problem is exacerbated when you attempt to add third-party components or plugins; what if two or more code sets implement a ?Database? or ?User? class?
Until now, the only solution has been long class/function names. For example, WordPress prefixes every name with ?WP_?. The Zend Framework uses a highly descriptive naming convention that results in long-winded class names such as
1 |
Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive. |
Name collision problems can be solved with namespaces. PHP constants, classes, and functions can be grouped into namespaced libraries.