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

PieceWhat it gives youRead
LayerA Composer package with "type": "layer", installed through a local path repositoryLayers
BucketsThe folders that hold the layers: functional/ and technical/ by defaultBuckets
Boundariesosdd:check fails when a layer uses a layer it does not require, or when layers require each otherBoundaries
Layer providerEach layer wires its own migrations, seeders, routes, views and configService providers
Artisan twinsosdd:model, osdd:controller and every other make:* twin write inside the layer you pickGenerators

Where to go next

Installation

Requirements and the one Composer command.

Quick start

Convert a fresh project and create your first layer.

Existing application

Add layers next to app/, one domain at a time.

Add a domain

From an empty layer to a tested CRUD resource.