supplycart / domains
Domain Manager
Requires
- php: ^8.5
- illuminate/console: ^13.0
- illuminate/contracts: ^13.0
- illuminate/support: ^13.0
Requires (Dev)
- laravel/pint: ^1.27
- orchestra/canvas: ^11.0
- orchestra/testbench: ^11.0
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-03 02:16:30 UTC
README
A lightweight, route-focused domain registry for Laravel 13.
The package keeps domain bootstrapping deliberately small: it registers each domain's routes, while Laravel handles events, model observers, and authorization policies through its native discovery and attribute APIs. When routes are cached, the configured domains are not loaded at all.
Requirements
- PHP 8.5 or later
- Laravel 13
Installation
Install the package and publish its configuration:
composer require supplycart/domains:^2.0 php artisan vendor:publish --tag=domains-config
Creating a domain
Generate a domain with Artisan:
php artisan make:domain User
This creates the domain under app/Domains/User, including its domain class,
model, policy, controller, and routes file.
Register the generated domain class in config/domains.php:
<?php declare(strict_types=1); use App\Domains\User\User; return [ 'modules' => [ User::class, ], ];
The generated domain owns its route registration:
<?php declare(strict_types=1); namespace App\Domains\User; use Supplycart\Domains\Domain; final class User extends Domain { public static function registerRoutes(): void { require __DIR__.'/Http/routes.php'; } }
Domains without routes can inherit the default no-op implementation.
Queued scaffolding
Use the --queues option to also generate an event, a discoverable listener,
and a queued job:
php artisan make:domain User --queues
Discover domain listeners from bootstrap/app.php:
->withEvents(discover: [ __DIR__.'/../app/Domains/*/Listeners', ])
The generated model is linked to its policy with Laravel's #[UsePolicy]
attribute. Register model observers with Laravel's #[ObservedBy] attribute.
Production optimization
Run Laravel's optimizer during deployment or image creation:
php artisan optimize
Once routes are cached, the package skips the configured domain list entirely.
Upgrading from version 1
Version 2 removes domain-level $listeners, $observers, $policies, init(),
and reflection-based route discovery. When upgrading:
- Move listeners to Laravel event discovery.
- Register observers with
#[ObservedBy]. - Register policies with
#[UsePolicy]. - Implement
registerRoutes()explicitly in domains that own routes.