Skip to content

STAGES.md lists non-existent event subscription methods #702

@Disr0

Description

@Disr0

I am trying to log unsuccessful api calls that result in internal server error, by subscribing to the onMessage event.
Problem is - there is no such method to subscribe to any of the events, unlike listed in stages.md file.

use Luracast\Restler\Restler;
use Luracast\Restler\Defaults;
$api = new Restler();
$api->onMessage(function () use ($api) {
    $error = $api->responseCode == 500;
    if ($error) {
        $request = $api->getRequestData();

        $log = [
            'method'   => $api->requestMethod,
            'url'      => $api->url,
            'status'   => $api->responseCode,
            'route'    => $api->apiMethodInfo->className . '::' . $api->apiMethodInfo->methodName,
            'data'     => $request['request_data'] ?? null,
            'error'    => $api->exception ? $api->exception->getErrorMessage() : null,
        ];
    
        Config::instance()->logger->write($log);
    }
});
$api->handle();

Code above results into:
[2026-04-13 14:33:05] Call to undefined method Luracast\Restler\Restler::onMessage()

I couldn't find code responsible for these methods by searching the source code for events listed in stages.md, I'm not sure if they even exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions