Namespaces seem like a natural fit for organizing types in external modules, but they introduce several limitations:
Imagine using a separate cup for each type of candy (e.g., Twix, PeanutButterCup). This approach is inefficient because you end up with multiple cups, and it's not clear how the candies are related.
Instead, it's better to organize the candies based on their file system location, similar to how modules are organized within a project.
Export as close to the top level as possible:
Use modules/namespaces sparingly:
The above is the detailed content of How to Organize External Modules Without Namespaces: Beyond the Candy Cup Analogy?. For more information, please follow other related articles on the PHP Chinese website!