3.0Boundary checks and the layer graph

Split your Laravel app into domain modules.

Each domain of your app becomes its own Composer package, with its models, migrations, routes, tests and service provider. Modules declare the modules they depend on, and one Artisan command checks that the code respects it, on every pull request.

$composer require lomkit/laravel-osdd

lomkit/laravel-osdd · PHP 8.3+ · Laravel 13 · MIT license

Three commands

From one app/ folder to checked modules

The package calls each module a layer. Create them with Artisan, and let the boundary check catch the shortcuts.

Terminal
~/shop $ php artisan osdd:start --force
INFOLayer functional/users created at functional/users.
INFOLayer technical/osdd created at technical/osdd.
INFODeleted app/ directory.
INFODeleted config/ directory.
INFOEmptied database/ directory, kept database/database.sqlite.
INFOCongratulations! Your project is ready for OSDD. Create your first layer with php artisan osdd:layer.
◇Run composer update now?Yes
INFORunning composer update...
~/shop $ php artisan osdd:layer functional/orders --generators=model,provider
INFOModel [functional/orders/src/Models/Order.php] created successfully.
INFOLayer functional/orders created at functional/orders.
◇Run composer update now?Yes
INFORunning composer update...
~/shop $ php artisan osdd:check
ERRORfunctional/orders uses functional/users but does not require it.
functional/orders/src/Models/Order.php:7Functional\Users\Models\User
ERROR1 boundary violation in 3 layers.
# functional/orders/composer.json
+ "require": { "functional/users": "*" }
~/shop $ php artisan osdd:check
INFONo boundary violation in 3 layers.

Output shortened to the lines of each command that matter here.

The layer graph

Dependencies you can see, and a check that enforces them

Each layer lists the layers it requires in its own composer.json. Point at a layer to see what it may use and who depends on it.

requiresrequired by

functional/orders

Requires
functional/catalogfunctional/users
Required by
functional/billing
  • osdd:check fails if it uses a class of a layer it does not require.
  • osdd:remove refuses it while functional/billing requires it.

$ php artisan osdd:graph

graph LR

    …six node lines

functional_billing --> functional_orders

functional_billing --> functional_users

functional_billing --> technical_payments

functional_orders --> functional_catalog

functional_orders --> functional_users

$ php artisan osdd:check

# no cycle in the layer requirements

Built for coding agents

Your agent stops writing in app/

The package ships a Laravel Boost skill. It teaches your agent where code goes in a modular app: read the map first, require a layer before using it, generate inside the right layer.

Set up the Boost skill
Add refunds to billing.
  1. php artisan osdd:list --json

    Reads every layer: path, namespace, providers, requirements, health.

  2. php artisan osdd:graph --format=json

    Checks that functional/billing requires functional/orders.

  3. php artisan osdd:model Refund --layer=functional/billing

    Writes the model inside the layer, never in app/.

  4. php artisan osdd:check --format=json

    Gets a machine-readable verdict on the boundaries.

osdd:list --json, one layer (excerpt)

{
    "name": "functional/billing",
    "path": "functional/billing",
    "namespace": "Functional\\Billing\\",
    "requires": ["functional/orders", "functional/users"],
    "health": { "installed": true, "test_suite": true }
}

Give your next domain its own package

Start on a fresh Laravel 13 app with osdd:start, or move an existing app one domain at a time.

$composer require lomkit/laravel-osdd

Laravel OSDD (Open Source Driven Development) is MIT licensed and maintained by Lomkit.