Actually i'm using this project directory structure http://framework.zend.com/manual/1.12/en/project-structure.project.html

But recently i started using namespaces in all my php-classes like:


and now I'm a little bit confused on where should i put all this directories in order to maintain a correct folder structure.
In the old project directory structure i also wrote directory names in lowercase, but now with namespaces i saw that most frameworks use camelcase like in the example above.

Any help would be appreciated.


1 Answer 1


Most modern PHP projects are structured much like a Java package; ie a top level source folder, with subdirectories for each vendor, containing subdirectories for individual packages and so on.

However, because PHP doesn't have the same kind of loading of classes as a language like Java, it loads its classes using an autoload function. This means that files must be in a predictable location, or else be missed by the loader.

The PSR-0 and PSR-4 specifications from the PHP Framework Interop Group (PHP-FIG) are intended to standardise the stucture of packages. These specifications are adopted and implemented by pretty much all 1 modern (see: last few years) PHP libraries, packages and applications; aidedin no small part, I'm sure, by Composer.

In short, the PSR-0 specification requires that, under a given directory, files be structured and named according to the namespace of the single class they contain. For example, if the source directory is src and you have a class My\Simple\Class, then your class could be found at


1 I can't think of a single project off the top of my head, but I'm sure there are some out there.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.