3.1 Projects directories

While the framework leaves you the maximum flexibility in organizing your code, in this paragraph you will find a suggested directories structure that will provide you a well organized, secure and scalable file system structure. The main goals are:

  • to provide security separations between php code and frontend assets;
  • make easy the work of different skilled people (php developers, frontend developers, DBA);
  • easy integration with version control systems (Git, Bazaar, SVN).

Let’s assume our project root directory to be /var/www/myproject.com.
This is the suggested directories tree:

  • data/

    • assets/
    • backup/
    • cache/
    • logs/
  • httpdocs/

    • css/
    • img/
    • js/
    • index.php
  • private/

    • apps/
    • lib/
    • metadigit-core.ini
    • system-context.xml
  • tmp/

2.4.1 “data” directory

📘

The “data” directory MUST be writable by webserver.

All the suggested sub directories will automatically created by the framework. However, you can customize them during the bootstrap (see chapter 3.2).

2.4.2 “httpdocs” directory

The “httpdocs” directory is the commonly named “public dir” on the webserver, and it contains static resources files as images, css, javascript libraries and files, and the bootstrap file index.php.
It can contain also php templates (see chapter 10 on views), to help frontend developers to work on html/css/js code, but for an enforced security structure is better to store templates under the “private” directory.

🚧

SECURITY TIP

The “httpdocs” directory should be NOT writable by webserver.

2.4.3 “private” directory

This is the root directory of all project code, including configuration files and libraries.
You are encouraged to store all libraries (open source / commercial libraries as ..., or any external component that you will not modified...) in the private/libs directory, while defined a top level directory for your own code as private/${NAMESPACE}, where ${NAMESPACE} will be the top level namespace of your own php code, usually the name of the project.

Example
Let’s assume your project is a blog system, requiring open source libraries and Swift Mailer and ...., you can create the following directories tree:

  • private/
    • myproject/
      • Controller.php
      • Model.php
    • libs/
      • swift-mailer-4.3.0/
      • xxx-library-x.x.x/
🚧

SECURITY TIP

The “private” directory should be NOT writable by webserver.