Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Cqrs Php Laravel Package

black/cqrs-php

Minimal CQRS command bus for PHP/DDD without event sourcing. Define Command and CommandHandler, register handlers to commands, then dispatch via a single Bus. Includes optional Symfony bundle integration with service tags for handler registration.

View on GitHub
Deep Wiki
Context7

Implements CQRS (for DDD in PHP)

Frequently asked questions about Cqrs Php
Can I use this package in Laravel without Symfony?
Yes, but manually. The package has no native Laravel support, so you’ll need to bind the Bus to Laravel’s container via a ServiceProvider. The Symfony bundle is optional and not required for Laravel projects. Start with basic DI setup in `AppServiceProvider` to register the Bus and handlers.
What Laravel versions does this package support?
The package has no explicit Laravel version constraints, but it requires PHP ≥5.4. Test compatibility with your Laravel version (e.g., 8.x, 9.x) for dependency conflicts, especially if using the Symfony bundle. No Laravel-specific features are included, so integration is manual.
How do I handle read models (queries) in this package?
This package focuses *only* on commands (CQRS write side). Read models must be implemented separately—typically via repositories, Eloquent queries, or Laravel’s query builder. For full CQRS, pair this with a separate query bus or Laravel’s built-in services.
Is this package actively maintained? Should I use it in production?
The repository is archived with no recent updates, so long-term maintenance is uncertain. Use it cautiously in production, especially if you need PHP 8+ features or security patches. Consider alternatives like `spatie/laravel-command-bus` for active support.
How do I integrate this with Laravel’s queue system for async commands?
The package’s Bus is synchronous. To use Laravel Queues, wrap the `bus->handle()` call in a Job class and dispatch it via `dispatch()`. Example: `Bus::dispatch(new MyCommand($data))` (custom wrapper needed). No built-in async support exists.
What’s the difference between this and Laravel’s built-in Artisan commands?
This package enforces a stricter DDD/CQRS pattern with explicit `Command` and `CommandHandler` interfaces, while Artisan commands are simpler CLI tools. Use this for domain logic (e.g., business workflows) and Artisan for admin tasks (e.g., migrations, cron jobs).
Does this package support transactions or distributed buses (e.g., RabbitMQ)?
No. The Bus handles commands synchronously without transaction management or distributed messaging. For transactions, use Laravel’s DB transactions around `bus->handle()`. For distributed buses, integrate a third-party library like `php-amqplib` manually.
How do I register handlers dynamically (e.g., via service tags in Laravel)?
The Symfony bundle supports service tags (`black_cqrs.handler`), but Laravel lacks native support. Manually register handlers in a ServiceProvider using `$bus->register()` or leverage Laravel’s `bind()` to auto-wire handlers. Example: `app()->bind(MyCommand::class, MyHandler::class);`.
Are there alternatives for Laravel that offer more features?
Yes. For a Laravel-native solution, try `spatie/laravel-command-bus` (supports queues, middleware, and Laravel’s ecosystem). For event sourcing, consider `spiral/framework` or `cubex/laravel-event-sourcing`. Evaluate based on your needs (e.g., async, queries, or DDD rigor).
How do I test command handlers with this package?
Mock the Bus in tests to verify handler execution. Example: `$bus = $this->createMock(Bus::class); $bus->expects($this->once())->method('handle')->with($command);`. Test handlers in isolation by injecting dependencies. No built-in testing utilities exist, so use PHPUnit’s DI tools.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
babenkoivan/elastic-client
innmind/static-analysis
innmind/coding-standard
datacore/hub-sdk
alengo/sulu-http-cache-bundle
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity