Getting Started
Introduction
What Laravel OSDD is, the problem it solves, and how its pieces fit together.
Laravel OSDD (Open Source Driven Development) lets you split a Laravel application into layers: one Composer package per domain, living in your repository, with its own models, migrations, seeders, tests, routes and service provider.
The problem
A fresh Laravel application keeps every domain in the same folders:
app/
Models/User.php
Models/Order.php
Models/Invoice.php
Http/Controllers/UserController.php
Http/Controllers/OrderController.php
Http/Controllers/InvoiceController.php
...
database/migrations/ ← every table of every domain
tests/Feature/ ← every test of every domain
Nothing separates billing from orders. Migrations, seeders and tests are global, any class can use any other one, and the dependencies between domains only exist in people's heads.
The OSDD way
Each domain owns a package, and declares the packages it depends on:
functional/
users/
composer.json ← "functional/users"
src/Models/User.php
database/migrations/
tests/
orders/
composer.json ← "functional/orders", requires "functional/users"
src/Models/Order.php
src/Providers/OrdersServiceProvider.php
database/
routes/
tests/
technical/
osdd/
composer.json ← "technical/osdd": the OSDD configuration
config/osdd.php
functional/holds the business domains:users,orders,billing.technical/holds the shared infrastructure: configuration, authentication wiring, observability.
The application stays one Laravel application: one artisan, one database, one deployment. The layers only change where the code lives and who may use it.
How the pieces fit
| Piece | What it gives you | Read |
|---|---|---|
| Layer | A Composer package with "type": "layer", installed through a local path repository | Layers |
| Buckets | The folders that hold the layers: functional/ and technical/ by default | Buckets |
| Boundaries | osdd:check fails when a layer uses a layer it does not require, or when layers require each other | Boundaries |
| Layer provider | Each layer wires its own migrations, seeders, routes, views and config | Service providers |
| Artisan twins | osdd:model, osdd:controller and every other make:* twin write inside the layer you pick | Generators |