Search code examples
phpstructureproject-managementdirectory-structureproject-structure

Organizing files and folders structure


I've been working with web-based solutions for some years now, Mostly PHP and WordPress projects, as this refers to. I'm not quite sure, if I structure my projects in the best way.

So, how do I structure my project in the right way?

For example, I have a project where i use Yarn for package control and gulp for my SASS and jQuery. Here my structure looks like this:

  • assets

    • css
      • style.css
      • style.min.css
    • sass
      • style.scss
    • js
      • scripts.js
      • scripts.min.js
    • img
  • node_modules

    • Bootstrap
    • jQuery
    • And so on
  • root

    • header.php
    • index.php
    • page.php
    • footer.php
    • gulpfile.js
    • package.json
    • yarn.lock

Isn't there a best practice on this? I can't find any professional page telling about this, and those that do exist, says different things.. There must be some type of guideline, even though everyone is different.


Solution

  • There is one result of the research effort scanning every package listed on https://packagist.org detailing which directories are being used by the vast majority of packages, i.e. what most people unconsciously agreed upon without coordination:

    https://github.com/php-pds/skeleton

    The short summary for directories:

    If a package has a root-level directory for ...     
                                ... then it MUST be named:
    command-line executables    bin/
    configuration files         config/
    documentation files         docs/
    web server files            public/
    other resource files        resources/
    PHP source code             src/
    test code                   tests/