I have two folders in my project: APPLICATION and SYSTEM. System contains folders such as CONFIG, CORE, HTML, URL. Each one of them contain some sets of classes.
I use this convention: the namespace of the class mirrors its file structure – this allows me to autoload them easily.
So: \Project_Name\System\Core\Foo is placed in System/Core/Foo.php.
However, calling such a long names is not the quickest, and nicest way for users of my code. Two questions then:
- Is it O.K. to create a couple of empty classes with the namespace like \Project_Name? With one “use” keyword in application classes I would get rid of the problem. But as a consequence I’d get a lot of empty classes and folder structures in a strange folder in “system/”.
- Or maybe I should be simply using
\Project_Namein every class? This however would make me push to create longer class names which would mirror the file structure, and make autoloading less understandable.
What do you think is the best way?
You forgot solution 3: Use aslias
The problem with your both solutions is, that you let your laziness decide about your applications structure.