BeforeStartApiRouteEvent
BeforeStartApiRouteEvent is dispatched while NexoPOS starts loading API routes. Modules can use it to register API routes or run setup that must happen before the main API route definitions are loaded.
Where It Runs
This event is dispatched in routes/api.php before NexoPOS includes the main API route definitions.
Available Properties
- This event does not expose constructor properties. It is used as a lifecycle signal while route files are being loaded.
Listener Example
<?php
use App\Events\BeforeStartApiRouteEvent;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Route;
Event::listen( BeforeStartApiRouteEvent::class, function () {
Route::prefix( 'my-module-api' )->group( function () {
Route::get( 'status', fn () => [ 'status' => 'ok' ] );
} );
} );
Summary
- Use this event when a module needs to register routes during the matching route bootstrapping phase.
- Register only the routes that belong to the current route file context.