Command/Query handlers from controllers). However, Laravel’s native routing is controller-centric, requiring a paradigm shift in request handling.RequestHandler with Laravel’s Illuminate\Http\Request.CqsRouter. This is highly invasive and may conflict with Laravel’s route caching (php artisan route:cache).HandlerLocator) may need custom binding logic to work with Laravel’s bind() or tag() methods.Illuminate\Foundation\Http\Kernel) differs from Symfony’s. Request decoding (e.g., JSON → DTO) may clash with Laravel’s built-in request parsing.RequestDecoder, ResponseConstructor), requiring updated unit/integration tests for existing routes.AccessValidator) may rely on Symfony’s security system, needing Laravel alternatives (e.g., Gates/Policies).App\Exceptions\Handler)?LaravelRequestDecoder, LaravelResponseConstructor).Router must be extended or replaced.symfony/http-foundation, symfony/dependency-injection) for compatibility.HttpKernel for performance)./api/commands/create-user) alongside existing Laravel routes.CqsRouter.RouteCollection.TrimStrings, ConvertEmptyStringsToNull).Request class may interfere with DTO decoding. Solution: Use Symfony\Component\HttpFoundation\Request as a base.SerializerJsonResponseConstructor, ensure Symfony’s Serializer is installed (symfony/serializer).AccessValidator with Laravel’s Gates/Policies or a custom validator.composer require digital-craftsman/cqs-routing symfony/http-foundation symfony/dependency-injection
php artisan vendor:publish --provider="DigitalCraftsman\CQSRouting\CqsRoutingServiceProvider").AppServiceProvider to bind CQS components:
$this->app->bind(\DigitalCraftsman\CQSRouting\RequestDecoder\RequestDecoderInterface::class, \App\CQSRouting\LaravelRequestDecoder::class);
LaravelRequestDecoder, LaravelResponseConstructor, etc.bootstrap/app.php to use CqsRouter:
$app->router->setRouter(new \DigitalCraftsman\CQSRouting\CqsRouter($app->make(\DigitalCraftsman\CQSRouting\RequestHandlerInterface::class)));
# config/cqs_routes.yaml
commands:
App\Application\Commands\CreateUserCommand:
path: /api/users
methods: [POST]
decoder: App\CQSRouting\DTO\CreateUserRequestDTO
LaravelRequestDecoder).How can I help you explore Laravel packages today?