LaraFly
Laravel underneath. Clear boundaries throughout.
A structured application layer on Laravel 13. Use PHP attributes to describe components, HTTP controllers, transaction boundaries, and security while keeping Laravel routing, Eloquent, and its container underneath.
- PHP 8.3+
- Laravel 13
- Composer workspace
The building blocks,
explained.
Explore what this implementation provides, with a direct path to the code behind each capability.
- Attribute-driven components
Describe components and their dependencies with PHP attributes. Compile their definitions into manifests that the Laravel container can load and resolve.
Explore this capability- HTTP controllers on Laravel
Map controller attributes onto Laravel routes. Bind request data, validate DTOs, and expose application results through familiar HTTP responses.
Explore this capability- Repositories and transactions
Build repositories over Eloquent with derived queries and explicit SQL where needed. Apply transactional boundaries to application handlers and translate database failures into application-facing exceptions.
Explore this capability- CQRS application operations
Dispatch commands to focused handlers through a pipeline for validation, authorization, correlation, and metrics. Keep domain-event publication tied to the transaction infrastructure.
Explore this capability- A transactional outbox
Write domain events into the outbox on the aggregate’s own database connection, inside its transaction. A rollback removes both the business change and its pending event.
Explore this capability- Method security
Apply authorization and filtering rules around application methods. When enabled, the security interceptor evaluates pre-rules before invoking the method and post-rules against its result.
Explore this capability
From the source
See the ideas
in real code.
Verbatim query-handler class from the Lumen sample: constructor-injected wallet repository, nullable balance result in minor units. The source file above the excerpt contains its namespace and imports.
View the complete source#[QueryHandler]
final class GetBalanceHandler
{
public function __construct(private readonly WalletRepository $wallets) {}
public function handle(GetBalance $query): ?int
{
$wallet = $this->wallets->findById($query->walletId);
return $wallet?->balanceMoney()->minorUnits;
}
}
Follow a wallet from request to balance.
Lumen is the companion wallet and ledger application. Follow its real controller, command handler, and repository to see how the layers work together.
Receive the request
WalletController binds and validates the request body, then sends an OpenWallet command. The HTTP boundary stays focused on input and the response.
Apply the business operation
OpenWalletHandler creates the wallet aggregate and saves it through WalletRepository. The Transactional attribute gives the operation an explicit database boundary.
Read the balance
Trace the balance endpoint through QueryBus and GetBalance. The REST tests open a wallet, deposit funds, and read the updated balance through the same application.

Learn by building
LaraFly by Example
Hexagonal PHP Microservices on Laravel 13 with the Firefly Framework
Build the Lumen wallet service on Laravel, from components and HTTP endpoints to repositories, CQRS, transaction boundaries, security, and the outbox.
English and Spanish · PDF and EPUB · v26.09.1
Keep exploring.
Follow the projects and references connected to LaraFly.
