Search code examples
phpcoding-style

Do you prefix your classnames?


Simple question : do you prefix your PHP classes (for example your library classes) with the name of your company ?

Example : Zend prefix everything with "Zend_", but that's normal because this is a framework (so they want to avoid conflicts). Should I do the same for the library classes of my company ? Will I ever get conflicts ?

I think this is easier to use without the prefix (shorter names), but is that a good practice to have a prefix ?


Solution

  • PHP has namespaces. You should use them instead of prefixing everything with a name.

    At the very least, your developers will thank you when they don't have to keep typing MyFrameworkName... just to start using one of your classes.