What is the most scalable PHP-based directory structure for a large site?

Viewed 40483

I am creating a very large PHP MVC-based site that will have a large library of php classes, javascripts, and many css files (not to mention a large amount of files for the MVC).

For the first time ever, I am actually taking the time to plan out a clean and organized directory structure.

What directory structures do you typically use, and which will be easiest to manuever when there are thousands of files?

10 Answers

This is the structure i'm using currently,

public/           
  assets/         /* js, css, imgs, ... */
  index.php
src/
  config/         /* for config files */
  helpers/        /* for functions */
  libraries/      /* for free classes that are not MVC classes */
  models/         /* for M in MVC */
  views/          /* for V in MVC */                   
  controllers/    /* for C in MVC */
  vendor/         /* for vendors files */
  uploads/        /* for uploaded images, docs, ... */

Even though the question is abit old, I still think it is wise to suggest the latest scaleable application structure which I have been working in my SOA based application and working absolutely fine.

myApplication/

    app/
        config/ 
        +         this can include custom MVC structure
    cli/ 
    docker/
    lib/        - most commonly reusable components
    logs/
    public/     - should contain all publicly exposable web contains
    sql/        - db migration stuffs
    tests/      - compulsory test
    tools/      - application addon tools like any kinds of rulset etc
    vendor/
Related