utilitarian / laravel-toolkit
Laravel Utilitarian Toolkit - Lightweight CQRS, State Machines, and utilities for Laravel
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/utilitarian/laravel-toolkit
Requires
- php: ^8.3
- illuminate/contracts: ^11.25|^12.0
- illuminate/support: ^11.25|^12.0
Requires (Dev)
- laradumps/laradumps: ^4.0
- laravel/pint: ^1.13
- orchestra/testbench: ^10.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
Suggests
- laradumps/laradumps: Enhanced debugging and dumping for Laravel (^4.0)
This package is auto-updated.
Last update: 2026-01-04 00:20:22 UTC
README
Laravel Utilitarian Toolkit - A lightweight CQRS implementation for Laravel, providing source-agnostic operations, State Machines, and additional utilities.
Philosophy
Events as side-effects. Pragmatic over dogmatic.
This is a lightweight, pragmatic approach to CQRS - not a full CQRS implementation. The toolkit focuses on practical solutions over architectural dogma.
Features
- Query - Reading from any source (DB, API, AI, files)
- Command - Writing to any source (DB, API, files, queues)
- Action - Orchestrating Query/Command with business logic
- State Machine - State management for domain models
- Lightweight DTOs - Automatic property mapping with reflection
- Middleware Support - Global and custom middleware for operations
Requirements
- PHP 8.3+
- Laravel 11+
Installation
Install the package via Composer:
composer require utilitarian/laravel-toolkit
The service provider will be automatically registered via Laravel's package discovery.
Optionally, publish the configuration file:
php artisan vendor:publish --tag=utilitarian-config
Development
Setup
Clone the repository and install dependencies:
git clone https://github.com/vasiliishvakin/utilitarian-laravel-toolkit.git
cd utilitarian-laravel
composer install
Running Tests
The package uses Pest for testing with Orchestra Testbench:
composer test # or vendor/bin/pest # With coverage composer test:coverage
Code Style
The package uses Laravel Pint for code styling:
# Fix code style composer lint # Check code style without fixing composer lint:test
Architecture
Core Concepts
The toolkit is built around three operation types:
- Query - Read operations from any source
- Command - Write operations to any source
- Action - Business logic orchestrating queries and commands
Buses
- QueryBus - Execute queries:
QueryBus::execute() - CommandBus - Execute commands:
CommandBus::execute()
Design Principles
- SRP - One class = one operation
- Explicit buses - Always use
QueryBus::execute()/CommandBus::execute() - Fluent API - Flexible configuration before execution
- Composition - Pipeline for complex scenarios
- Laravel-way - Don't fight the framework
- Pragmatic - Functionality over dogma
What NOT to Use
- Repositories - Covered by Query pattern
- Services - Covered by Action pattern
- Interfaces everywhere - Considered excessive
- DTOs everywhere - Only when mixing sources/data or when logic requires it
License
Licensed under the Apache License 2.0. See LICENSE file for details.
Credits
Created by Vasilii Shvakin