-
Notifications
You must be signed in to change notification settings - Fork 0
Action Definition
lpachecob edited this page Mar 24, 2026
·
4 revisions
In BOUNDLY, an Action is a single Use Case. You don't need a routes/*.php file. Just add an attribute to your Action class.
Required to register a class as an API endpoint.
| Property | Default | Description |
|---|---|---|
resource |
NULL |
The API path (e.g., 'auth/login'). |
method |
'GET' |
The HTTP method (GET, POST, PUT, DELETE). |
middleware |
[] |
Array of Laravel middleware to apply. |
#[Action(resource: 'users/register', method: 'POST')]
class RegisterUserAction { ... }Your Action class must implement a main entry point. While BOUNDLY doesn't require an interface, the Generic Controller will try to execute it as a handler for the resource.
// Application/Users/Actions/CreateUserAction.php
use Infrastructure\FrameworkCore\Attributes\UseCase\Action;
#[Action(resource: 'users', method: 'POST')]
class CreateUserAction
{
public function handle(array $data)
{
// Your Use Case logic here...
// Validation, Entity creation, Event dispatching.
return ['status' => 'success', 'data' => $data];
}
}#[Action(
resource: 'profile/private',
method: 'GET',
middleware: ['auth:sanctum', 'throttle:api']
)]
class GetPrivateProfileAction { ... }-
Single Responsibility: Each class does ONE thing (e.g.,
ResetPasswordAction). -
Declarative Routing: Routes live where they are used. No more hunting through a 2000-line
routes/web.php. - Decoupled: Your actions are cleaner, and BOUNDLY's registry finds them automatically during its scan.
Next Step: Behavioral-Traits 🛡️