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.
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.
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.