My company has created a modular PHP framework over the years, beginning long before PHP 5.3 added namespaces. Recently, we decided to start using namespaces in our library's new code, and we intend to namespace old code eventually. However, we have a few issues we are trying to work out to determine if adding namespaces to a pre-v5.3 codebase is just not a good idea:
- Can I namespace a class but also import (use) the global namespace so all global classes do not need a
\
prefix? - If we namespace an existing class in our library, how can we prevent all existing projects from breaking as soon as the framework upgrades? For example, can the library change the name of class
ThemeEngine
to\module\theme\ThemeEngine
, but the existing websites callThemeEngine
without any code modification? If so, what would that code look like?