# AppEvent events

> 1 FeatherPanel plugin events on AppEvent (1 emitted by the core): the event names, the arguments each listener gets, where they fire and a PHP listener for each.

Source: https://featherpanel.com/docs/plugins/events/app/

Part of the [plugin events reference](https://featherpanel.com/docs/plugins/events/). Listeners get the payload values as positional arguments in the order shown, cannot cancel the action, and must catch their own exceptions.

## Setup

Import `AppEvent` in your entry class and register listeners in `processEvents()`:

```php
<?php

namespace App\Addons\myplugin;

use App\App;
use App\Plugins\AppPlugin;
use App\Plugins\PluginEvents;
use App\Plugins\Events\Events\AppEvent;

class MyPlugin implements AppPlugin
{
    public static function processEvents(PluginEvents $event): void
    {
        $event->on(AppEvent::onRouterReady(), function ($router): void {
            App::getInstance(true)->getLogger()->info('[myplugin] router::Ready');
        });
    }

    public static function pluginInstall(): void
    {
    }

    public static function pluginUninstall(): void
    {
    }
}
```

## `AppEvent::onRouterReady()`

- Name: `router::Ready`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/AppEvent.php#L24)

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `router` | `$router` | `RouteCollection` |

When it fires (1 site)

-   [`App::bootHttp`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/App.php#L250)

```php
$event->on(AppEvent::onRouterReady(), function ($router): void {
    App::getInstance(true)->getLogger()->info('[myplugin] router::Ready');
});
```
