PHP is a largely flexible language, I could do this anyhow and anywhere. However, what would you consider to be best practices for structuring large projects?
I have built a bespoke CMS for a client, but as it was my first venture into a large project its a bit of a mess. There’s files everywhere, with a very bad folder structure.
A friend suggested that the only files that should sit in the root directory of the website are the “page” files – i.e. the files that actually have HTML in them and that you should have separate folders for each of the different elements, which can then be easily pulled into different pages with includes. Would everybody recommend this route or is it governed entirely by personal preference?
If starting a new project, consider using a Framework, or taking a look at how they do it.
Frameworks usually either dictate, or suggest, a directory structure.
Even if you don’t end up using one: The way they structure their projects usually comes from tons and tons of experience.
I personally like the Zend Framework way of structuring, and its Autoloader, best. But there are several options and philosophies out there.
Framework questions:
What PHP Framework to choose
Best PHP framework for an experienced PHP developer?
More Framework questions….
Generally related:
In a PHP project, how do you organize and access your helper objects?
How to use PHP for large projects?