Directory Structure
Table of Contents
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:
- lang
- en
- English translation files are here
- en
- rawassets
- Raw assets (eg SCSS files) are here
- views
- View template files are here
- errors
- html
- HTML error template files are here
- json
- JSON error template files are here
- html
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:
- Bootstrappers
- Console
- Console bootstrappers are here
- Http
- HTTP bootstrappers are here
- Console
- Console
- Commands
- Console commands are here
- Commands
- Events
- Events are here
- Listeners
- Event listeners are here
- Http
- Controllers
- HTTP controllers are here
- Middleware
- HTTP middleware are here
- Views
- View builders are here
- Controllers
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 your interfaces go here. This directory should house any code that interacts with storage, eg databases and cache.
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:
- framework
- This is meant for any configuration done by Opulence and is not meant to be used by your application
- logs
- This is where your log files go