Directory structure

A Herbie website is usually structured as follows:

project
├── site
├── vendor
└── web
    ├── assets
    ├── cache
    ├── media
    ├── .htaccess
    └── index.php

What these files and directories stand for can be seen in the following table:

File/Directory Description
project The project directory on the web server.
site The actual content of the website (see below). This directory is normally not accessible via the web. However, it can also be placed in the public directory.
vendor This directory is the Composer vendor and contains all dependent third-party libraries. This directory is not accessible via the web.
web The public directory of the web server. This can be accessed via the web browser.
web/assets The repository for JavaScript, CSS and image files, which are needed for the layout of the website.
web/cache The cache for files that should be publicly accessible, e.g. resized images.
web/media This directory contains files that are linked through the content. For example, images, PDFs, videos, MP3s, etc.
web/.htaccess If configuration option `components.urlManager.niceUrls` is enabled, this file must exist with corresponding instructions.
web/index.php The bootstrap file and part of Herbie. All requests to the web server go through this file.

Site directory

Normally one works exclusively in the site directory of the web project. This is usually structured as follows:

site
├── config
│   └── main.php
├── data
│   ├── animals.json
│   └── persons.yml
├── extend
│   ├── commands
│   ├── events
│   ├── middlewares_app
│   ├── middlewares_route
│   ├── plugins
│   ├── twig_filters
│   ├── twig_functions
│   ├── twig_globals
│   └── twig_tests
├── pages
│   ├── company
│   │   ├── about-us.md
│   │   ├── index.md
│   │   ├── our-vision.md
│   │   └── team.md
│   ├── contact.md
│   ├── index.md
│   └── services.md
├── runtime
│   ├── cache
│   │   ├── system
│   │   └── twig
│   └── log
└── themes
    └─ default
        ├── assets
        ├── default.html
        └── error.html

The following table shows what each of these files and directories stand for:

File/Directory Description
config The configuration directory with files in PHP format (the main file can also be a PHP file).
data The data directory where various data files in JSON or YAML format can be stored.
extend The directory with various customized extensions.
extend/commands Directory with customized console commands.
extend/events Directory with customized event listeners.
extend/middlewares_app Directory with customized application middlewares.
extend/middlewares_route Directory with customized route middlewares.
extend/plugins Directory with customized Plugins.
extend/twig_filters Directory with customized Twig Filters.
extend/twig_functions Directory with customized Twig Functions.
extend/twig_globals Directory with customized Twig Globals.
extend/twig_tests Directory with customized Twig Tests.
pages The CMS pages of the website. These are saved as text files (Markdown, Textile, Text, HTML).
runtime Directory with temporary files created during the program runtime.
runtime/cache Directory with cache files.
runtime/cache/system Directory with cache files for the system.
runtime/cache/twig Directory with cache files for Twig.
runtime/log Directory with log files from PHP or a PSR-3 compatible logger.
themes Directory with theme directories and files.
themes/default The directory with the default theme. Besides template files it contains CSS and JS files that are copied to the web assets directory at runtime.

.htaccess file

If configuration option components.urlManager.niceUrls is enabled, there must be an .htaccess file with appropriate instructions in the web directory.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

Thus, all page views are passed on to the central index file. This is important for search engine optimization, for example, but also for visitors to the website.

Note: The above configuration is designed for Apache web server.