packages-larajs-cqrs

Implement CQRS pattern in Laravel applications using larajs/cqrs.

2|Updated Sep 30, 2024
One-click install
npx skills add https://github.com/maingocthanhtan96/larajs-docs --skill packages-larajs-cqrs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: packages-larajs-cqrs
Source: https://github.com/maingocthanhtan96/larajs-docs/tree/main/.claude/skills/packages-larajs-cqrs
Command: npx skills add https://github.com/maingocthanhtan96/larajs-docs --skill packages-larajs-cqrs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill simplifies the implementation of the Command Query Responsibility Segregation (CQRS) pattern in Laravel applications, enabling better separation of concerns and improved scalability.

Core Features & Use Cases

  • Command & Query Handling: Define and manage commands and queries with dedicated handlers.
  • Bus Configuration: Configure command and query buses with customizable middleware and resolvers.
  • Attribute-Based Routing: Utilize attributes like #[Handler], #[Middleware], and #[ResetMiddleware] for streamlined handler and middleware registration.
  • Use Case: Efficiently manage complex application logic by separating write operations (commands) from read operations (queries), leading to cleaner code and easier maintenance.

Quick Start

Install the larajs/cqrs package using composer require larajs/cqrs:dev-main.

Frequently Asked Questions about packages-larajs-cqrs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement CQRS in a Laravel application?

To implement CQRS in Laravel, you can use the larajs/cqrs package to separate write operations via a command bus and read operations via a query bus, utilizing dedicated handlers for each action to improve code separation.

What is the Command Query Responsibility Segregation pattern used for in Laravel?

The Command Query Responsibility Segregation pattern in Laravel is used to separate write operation logic from read operation logic, enabling better separation of concerns, cleaner code maintenance, and improved application scalability for complex domains.

How do I register handlers and middleware in a Laravel CQRS setup?

You register handlers and middleware in a Laravel CQRS setup by utilizing PHP attributes like #[Handler], #[Middleware], and #[ResetMiddleware] for streamlined resolution, integrated directly with Laravel's service container for dependency injection.

Can I customize the command and query bus configuration with middleware in Laravel?

Yes, you can customize the command and query bus configuration in Laravel by defining custom middleware and resolvers, allowing you to intercept and manipulate bus execution pipelines for cross-cutting concerns.

When should I use a command bus versus a query bus in PHP?

You should use a command bus in PHP for executing write operations that change application state, and a query bus for fetching read data, ensuring that complex application logic remains cleanly separated and easier to maintain.

Does the larajs/cqrs package require external dependencies to function?

No, the larajs/cqrs package does not require external Skill dependencies to function; it operates within the Laravel ecosystem, leveraging the framework's native service container for dependency injection and bus configurations.