Directory Structure

Table of Contents

  1. Introduction
  2. bootstrap
  3. config
  4. public
  5. resources
  6. src
  7. tests
  8. tmp

Introduction

Opulence's directory structure was inspired by the best of ideas from frameworks like Laravel and Aura. The directories logically separate files based on their purpose. However, you are not chained to this structure. If you do decide to customize it, make sure you update the PSR-4 settings in composer.json as well as the relevant paths in config/paths.php.

bootstrap

This contains the code that actually boots up your application. It's probably best not to touch the contents unless you are sure you know what you are doing.

config

All configuration files for your application should go here. Console-specific configs are in the console subdirectory, and web-specific configs are in the http subdirectory. The environment subdirectory holds .env.*.php files to setup your server with environment variables.

public

Like the name implies, this is the directory that is publicly-accessible. Assets like CSS, JavaScript, and images should go under the assets subdirectory.

resources

This is where your views and other non-publicly-accessible files go. For example, SCSS files and un-minified JavaScript files belong here. The subdirectories under resources are:

src

This is where your project's core code goes. If it's a PHP class, it belongs in here. Opulence subscribes to the domain-driven design philosophy, which encourages you to separate your domain models from your application logic. The subdirectories under src are:

Application

The application layer stores code that is used to interface your domain logic with your presentation layer. It also contains classes that bootstrap your application. It contains the following subdirectories:

Domain

Your core business logic and models belong here. This is the heart of your application. This code is written to an interface. It's recommended that you add subdirectories for each domain type, eg Blog for all business logic and models dealing with blog posts.

Infrastructure

Your concrete implementations of interfaces that deal with external resources go here. For example, this directory should house any code that interacts with databases, cache, email, etc.

tests

Put your unit tests in this directory.

tmp

Any files that are generated by your application, such as compiled views, are stored here. This is different than the resources directory in that files here are meant to be read and written to by the application, not a developer. The subdirectories are: