The Neuron framework implements a comprehensive event system for decoupled communication between components. Events are dispatched when specific actions occur, and listeners can respond to these events.
This reference documents ALL events available across the entire Neuron framework, organized by component.
The event system consists of:
IEvent that represent occurrencesIListener that respond to events\Neuron\Application\CrossCutting\Event::emit()Application lifecycle and error handling events.
Event Name: application.crashed
Namespace: Neuron\Application\Events\ApplicationCrashedEvent
Fired when the application crashes due to a fatal error or uncaught exception.
Properties:
array $error - Error details containing: type, message, file, line, and optionally traceWhen Emitted: From error handlers (fatalHandler, globalExceptionHandler, or onCrash)
Use Cases:
Example Listener:
class AlertOnCrashListener implements IListener
{
public function event( $event ): void
{
if( !$event instanceof ApplicationCrashedEvent )
{
return;
}
// Send alert to Slack, PagerDuty, etc.
$message = "Application crashed: {$event->error['message']}";
// ... send alert
}
}
Event Name: application.shutting_down
Namespace: Neuron\Application\Events\ApplicationShuttingDownEvent
Fired when the application is shutting down gracefully.
Properties: None
When Emitted: In onFinish() method before application terminates
Use Cases:
Event Name: application.error
Namespace: Neuron\Application\Events\ErrorOccurredEvent
Fired when a PHP error occurs (non-fatal).
Properties:
int $errorNo - PHP error number (E_NOTICE, E_WARNING, etc.)string $message - Error messagestring $file - File where error occurredint $line - Line number where error occurredWhen Emitted: From phpErrorHandler() for non-fatal errors
Use Cases:
Event Name: application.fatal_error
Namespace: Neuron\Application\Events\FatalErrorEvent
Fired when a fatal PHP error occurs.
Properties:
string $type - Error type name (e.g., 'Fatal Error', 'Parse Error')string $message - Error messagestring $file - File where error occurredint $line - Line number where error occurredWhen Emitted: From fatalHandler() when fatal error is detected
Use Cases:
Job queue, worker, and scheduler events.
Event Name: job.processed
Namespace: Neuron\Jobs\Events\JobProcessedEvent
Fired when a job completes successfully.
Properties:
string $jobClass - Fully qualified class name of the jobarray $arguments - Arguments passed to the jobstring $queue - Queue name where job was processedfloat $executionTime - Execution time in secondsWhen Emitted: After job's run() method completes without throwing an exception
Use Cases:
Event Name: job.failed
Namespace: Neuron\Jobs\Events\JobFailedEvent
Fired when a job fails with an exception.
Properties:
string $jobClass - Fully qualified class name of the jobarray $arguments - Arguments passed to the jobstring $queue - Queue name where job failedThrowable $exception - The exception that caused the failureint $attempts - Number of attempts made so farWhen Emitted: When job's run() method throws an exception
Use Cases:
Event Name: job.max_attempts_reached
Namespace: Neuron\Jobs\Events\JobMaxAttemptsReachedEvent
Fired when a job exhausts all retry attempts and fails permanently.
Properties:
string $jobClass - Fully qualified class name of the jobarray $arguments - Arguments passed to the jobstring $queue - Queue name where job failedThrowable $exception - The final exception that caused permanent failureint $maxAttempts - Maximum number of attempts allowedWhen Emitted: When job fails and reaches maximum retry attempts
Use Cases:
Event Name: worker.started
Namespace: Neuron\Jobs\Events\WorkerStartedEvent
Fired when a queue worker starts processing jobs.
Properties:
string $workerId - Unique identifier for this worker instancearray $queues - Array of queue names this worker processesWhen Emitted: When worker begins its run loop
Use Cases:
Event Name: worker.stopped
Namespace: Neuron\Jobs\Events\WorkerStoppedEvent
Fired when a queue worker stops processing jobs.
Properties:
string $workerId - Unique identifier for this worker instanceint $totalJobsProcessed - Total number of jobs processed by this workerWhen Emitted: When worker gracefully shuts down or crashes
Use Cases:
Event Name: scheduler.job_triggered
Namespace: Neuron\Jobs\Events\SchedulerJobTriggeredEvent
Fired when the scheduler determines a scheduled job is due to run.
Properties:
string $jobName - Name of the scheduled jobstring $jobClass - Fully qualified class name of the jobstring $schedule - Cron expression for this jobstring|null $queue - Queue name if job is queued, null if run directlyWhen Emitted: When scheduler's cron expression evaluates to true and job is triggered
Use Cases:
HTTP request, view caching, and rate limiting events.
Event Name: request.received
Namespace: Neuron\Mvc\Events\RequestReceivedEvent
Fired when the MVC application receives an HTTP request.
Properties:
string $method - HTTP method (GET, POST, PUT, DELETE, etc.)string $route - Requested route/pathstring $ip - Client IP addressfloat $timestamp - Request timestamp (microtime)When Emitted: At the beginning of the request lifecycle, before routing and controller execution
Use Cases:
Event Name: view.cache_hit
Namespace: Neuron\Mvc\Events\ViewCacheHitEvent
Fired when a rendered view is served from cache.
Properties:
string $controller - Controller namestring $page - Page/view namestring $cacheKey - Cache key used for lookupWhen Emitted: When view caching system finds a valid cached version
Use Cases:
Event Name: view.cache_miss
Namespace: Neuron\Mvc\Events\ViewCacheMissEvent
Fired when a view must be rendered because no cache exists.
Properties:
string $controller - Controller namestring $page - Page/view namestring $cacheKey - Cache key that was not foundWhen Emitted: When view caching system does not find a cached version
Use Cases:
Event Name: rate_limit.exceeded
Namespace: Neuron\Mvc\Events\RateLimitExceededEvent
Fired when a request exceeds rate limit thresholds.
Properties:
string $ip - Client IP address that exceeded the limitstring $route - Route or endpoint that was rate limitedint $limit - Maximum requests allowedint $window - Time window in secondsint $attempts - Number of requests made in the windowWhen Emitted: By RateLimitFilter when client exceeds configured rate limit
Use Cases:
User authentication, content management, and system administration events.
Event Name: user.login
Namespace: Neuron\Cms\Events\UserLoginEvent
Fired when a user successfully logs in.
Properties:
User $user - User who logged instring $ip - IP address of the loginfloat $timestamp - Login timestamp (microtime)When Emitted: After successful authentication in Authentication::login()
Use Cases:
Event Name: user.login_failed
Namespace: Neuron\Cms\Events\UserLoginFailedEvent
Fired when a login attempt fails.
Properties:
string $identifier - Username or email used in failed attemptstring $ip - IP address of the failed loginfloat $timestamp - Failure timestamp (microtime)string $reason - Reason for failure (invalid_credentials, account_locked, account_inactive, user_not_found)When Emitted: When authentication fails in Authentication::attempt()
Use Cases:
Event Name: user.logout
Namespace: Neuron\Cms\Events\UserLogoutEvent
Fired when a user logs out.
Properties:
User $user - User who logged outfloat $sessionDuration - Session duration in secondsWhen Emitted: When user explicitly logs out in Authentication::logout()
Use Cases:
Event Name: email.verified
Namespace: Neuron\Cms\Events\EmailVerifiedEvent
Fired when a user successfully verifies their email address.
Properties:
User $user - User whose email was verifiedWhen Emitted: After successful email verification in EmailVerifier::verifyEmail()
Use Cases:
Event Name: password.reset_requested
Namespace: Neuron\Cms\Events\PasswordResetRequestedEvent
Fired when a user requests a password reset.
Properties:
User $user - User who requested password resetstring $ip - IP address of the requestWhen Emitted: After reset token is generated in PasswordResetter::requestReset()
Use Cases:
Event Name: password.reset_completed
Namespace: Neuron\Cms\Events\PasswordResetCompletedEvent
Fired when a user successfully completes a password reset.
Properties:
User $user - User who completed password resetstring $ip - IP address where reset was completedWhen Emitted: After password is successfully changed in PasswordResetter::resetPassword()
Use Cases:
Event Name: maintenance.enabled
Namespace: Neuron\Cms\Events\MaintenanceModeEnabledEvent
Fired when maintenance mode is enabled.
Properties:
string $enabledBy - Username or identifier of who enabled maintenance modestring $message - Maintenance message to display to usersWhen Emitted: When MaintenanceManager::enable() succeeds
Use Cases:
Event Name: maintenance.disabled
Namespace: Neuron\Cms\Events\MaintenanceModeDisabledEvent
Fired when maintenance mode is disabled.
Properties:
string $disabledBy - Username or identifier of who disabled maintenance modeWhen Emitted: When MaintenanceManager::disable() succeeds
Use Cases:
The following events already exist for content management operations:
user.created) - Fired when a new user is createduser.updated) - Fired when a user is updateduser.deleted) - Fired when a user is deletedpost.created) - Fired when a new post is createdpost.published) - Fired when a post is publishedpost.deleted) - Fired when a post is deletedpage.created) - Fired when a new page is createdpage.published) - Fired when a page is publishedpage.updated) - Fired when a page is updatedpage.deleted) - Fired when a page is deletedcategory.created) - Fired when a new category is createdcategory.updated) - Fired when a category is updatedcategory.deleted) - Fired when a category is deletedEvents and their listeners are configured in resources/config/event-listeners.yaml:
events:
user.login:
class: 'Neuron\Cms\Events\UserLoginEvent'
listeners:
- 'App\Listeners\LogUserLoginListener'
- 'App\Listeners\SendLoginNotificationListener'
job.failed:
class: 'Neuron\Jobs\Events\JobFailedEvent'
listeners:
- 'App\Listeners\AlertOnJobFailureListener'
rate_limit.exceeded:
class: 'Neuron\Mvc\Events\RateLimitExceededEvent'
listeners:
- 'App\Listeners\BlockAbusiveIpListener'
<?php
namespace App\Listeners;
use Neuron\Events\IListener;
use Neuron\Jobs\Events\JobFailedEvent;
use Neuron\Log\Log;
class AlertOnJobFailureListener implements IListener
{
public function event( $event ): void
{
if( !$event instanceof JobFailedEvent )
{
return;
}
// Send alert to Slack, email, etc.
Log::error( "Job failed: {$event->jobClass} - {$event->exception->getMessage()}" );
// ... send notification
}
}
Add your listener to resources/config/event-listeners.yaml:
events:
job.failed:
class: 'Neuron\Jobs\Events\JobFailedEvent'
listeners:
- 'App\Listeners\AlertOnJobFailureListener'
You can emit events from anywhere in your application:
use Neuron\Application\CrossCutting\Event;
use Neuron\Cms\Events\UserLoginEvent;
// Emit an event
Event::emit( new UserLoginEvent( $user, $ip, microtime( true ) ) );
| Component | Events |
|---|---|
| Application | ApplicationCrashedEvent, ApplicationShuttingDownEvent, ErrorOccurredEvent, FatalErrorEvent |
| Jobs | JobProcessedEvent, JobFailedEvent, JobMaxAttemptsReachedEvent, WorkerStartedEvent, WorkerStoppedEvent, SchedulerJobTriggeredEvent |
| MVC | RequestReceivedEvent, ViewCacheHitEvent, ViewCacheMissEvent, RateLimitExceededEvent |
| CMS | UserLoginEvent, UserLoginFailedEvent, UserLogoutEvent, EmailVerifiedEvent, PasswordResetRequestedEvent, PasswordResetCompletedEvent, MaintenanceModeEnabledEvent, MaintenanceModeDisabledEvent, UserCreatedEvent, UserUpdatedEvent, UserDeletedEvent, PostCreatedEvent, PostPublishedEvent, PostDeletedEvent, PageCreatedEvent, PagePublishedEvent, PageUpdatedEvent, PageDeletedEvent, CategoryCreatedEvent, CategoryUpdatedEvent, CategoryDeletedEvent |
Security Monitoring:
Error Tracking:
Performance Monitoring:
System Operations:
\Neuron\Application\CrossCutting\Event::emit() is calledevent-listeners.yamlIListener interfaceevent() method has correct signature