openclassrooms/use-case
A lightweight PHP package for expressing business logic as explicit, single-responsibility use cases. Keeps controllers and models thin, makes domain code testable and framework-agnostic, and integrates cleanly with Laravel applications.
Architecture fit
openclassrooms/use-case codifies the Command/Handler interactor pattern: a use case is a plain PHP object with an execute entry point, resolved and invoked by a dispatcher. This aligns well with a Laravel codebase that is already drifting toward thin controllers, form requests, and an application layer — it gives that drift a name and a file-layout convention. It composes cleanly with Laravel's existing Illuminate\Bus\Dispatcher and pipeline, but it is not a replacement for the framework's queue/bus; it is a structuring primitive layered on top. Teams running Actions or Jobs as their application layer will find conceptual overlap and must pick one as the canonical pattern before rollout, or the codebase will end up with two competing conventions.
Integration feasibility Single-vendor, MIT-licensed, Composer-installable, with a small public surface — all favorable. The practical gap is Laravel glue: there is no first-party service provider, no config file, and no documented container binding strategy. A TPM should budget a thin adapter package (provider + handler registration + interface bindings to Laravel's container) as day-one work. Because the package is small, that adapter is hours-to-days, not weeks — but it becomes internal code you now own and must test against framework upgrades.
Technical risk
DB::transaction and event model.Key questions
Stack fit Good fit for a Laravel 10+ / PHP 8.1+ service that already separates HTTP, application, and domain layers. Poor fit for a small CRUD app — the ceremony exceeds the benefit. Place it in the application layer, keep Eloquent confined to handlers/repositories, and return explicit result objects rather than raw models so the boundary stays honest.
Migration path Do not retrofit the whole codebase. Select one bounded context with real business rules (onboarding, billing, enrollment), convert its controllers to construct-and-dispatch a use case, and measure. Existing controllers keep working; the two styles coexist behind a route-level boundary. Once the pilot proves out, codify the pattern in a written convention doc and a scaffold/generator before expanding.
Compatibility Resolve the container bridge first: bind an interface-to-handler resolution strategy in a service provider so nested use cases and constructor injection work. Verify compatibility with Laravel's facades inside handlers — facades resolve statically and can hide dependencies the use-case pattern is meant to expose. If the package ships attributes/annotations, confirm they don't collide with Laravel's attribute scanning or Octane's long-lived worker state.
Sequencing
composer why-not check against current PHP/Laravel.make:use-case-style generator.Maintenance Low ongoing cost: no runtime dependencies of consequence, no migrations, no infrastructure. The real maintenance item is the internal adapter, which must be retested on every Laravel major. Assign a named owner; an unowned adapter is the most likely source of silent breakage.
Support No vendor SLA, no community, no Stack Overflow corpus. Support is entirely internal — expect a "if it breaks, we read the source" posture. That is acceptable for a package this small but must be stated explicitly to stakeholders rather than assumed away.
Scaling Stateless and horizontally trivial. Watch the application-level scaling hazards the pattern invites: use cases that accrete repository calls and produce N+1 queries, and use cases invoked inside loops. Enforce a rule that one use case equals one unit of work and one transaction boundary, and add query-count assertions in the adapter's base test case.
Failure modes
Ramp-up Expect one to two sprints for a squad to become productive: half a sprint for the pattern itself, the rest for the adapter, testing base class, and conventions. The concept is easy; the discipline of keeping handlers thin and dependency-explicit is what takes repetition. Budget for a short internal brown-bag and a reference implementation in the pilot module — that single example will do more than documentation.
How can I help you explore Laravel packages today?