Guides
Add a Domain
Take a new domain from an empty layer to a routed, authorized, seeded and tested resource.
This guide adds an invoices domain that depends on an existing functional/orders layer. Every file lands in functional/invoices, and nothing is written to app/.
Create the layer
php artisan osdd:layer functional/invoices \
--generators=provider,routes,test \
--requires=functional/orders \
--composer-update
providerwritesInvoicesServiceProvider, which already loads the layer's migrations, routes, views and translations.routeswrites the four route files:web.php,api.php,console.php,channels.php.--requiresdeclares the dependency onfunctional/ordersin the layer'scomposer.json, soosdd:checkaccepts it.--composer-updateinstalls the layer, so Laravel discovers its provider.
Generate the resource
php artisan osdd:model Invoice --all --layer=functional/invoices
--all creates every companion inside the same layer:
functional/invoices/
├── src/
│ ├── Models/Invoice.php
│ ├── Policies/InvoicePolicy.php
│ ├── Http/Controllers/InvoiceController.php
│ └── Http/Requests/StoreInvoiceRequest.php, UpdateInvoiceRequest.php
└── database/
├── factories/InvoiceFactory.php
├── migrations/<timestamp>_create_invoices_table.php
└── seeders/InvoiceSeeder.php
The seeder is registered in the layer provider with loadSeeders(). The policy needs no registration: Laravel finds Functional\Invoices\Policies\InvoicePolicy for Functional\Invoices\Models\Invoice by convention.
Add the routes
functional/invoices/routes/web.php
use Functional\Invoices\Http\Controllers\InvoiceController;
use Illuminate\Support\Facades\Route;
Route::resource('invoices', InvoiceController::class);
The provider's withRouting() already mounts this file in the web middleware group. See Routes.
Use the other layer
The migration can reference the orders table, and the model the Order model, because the layer requires functional/orders:
functional/invoices/src/Models/Invoice.php
use Functional\Orders\Models\Order;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
public function order(): BelongsTo
{
return $this->belongsTo(Order::class);
}
Test it
php artisan osdd:test CreateInvoiceTest --layer=functional/invoices
php artisan osdd:phpunit
php artisan test --testsuite=functional/invoices
osdd:phpunit adds the functional/invoices test suite to phpunit.xml. See Tests and CI.
Migrate, seed and check
php artisan migrate
php artisan osdd:seed --layer=functional/invoices
php artisan osdd:check
Coding agents follow the same steps with the Laravel Boost skill.