Search by

humble-guys / humble-core

humbleguys

Internal WordPress application framework for Humble Guys projects.

Package info

github.com/HumbleGuys/humble-core

pkg:composer/humble-guys/humble-core

Statistics

Installs: 2 962

Dependents: 11

Suggesters: 0

Stars: 3

Open Issues: 0

0.2.3 2026-11-30 11:22 UTC

README

humble-core

WordPress 404 routes

Register a custom not-found page using Route::wp('404', $handler). When no WordPress route matches, the router sets the main query to 404, sends the 404 status and no-cache headers, and resolves this registered route. If no 404 route is registered, it returns a plain Not Found response with status 404.

Controller and rendering exceptions still go through the server-error handler.

Server errors

An unexpected exception in a WordPress route or a GET, POST, PUT or DELETE route is logged and passed to the handler from Router::setServerErrorHandler. The handler gets the failed route, or null when no WordPress route matched, from getCurrentRoute():

$router->setServerErrorHandler(function (Throwable $e) use ($router): ?Response {
    \Sentry\captureException($e);

    return $router->getCurrentRoute()?->isApi() ? null : response(view('500'), 500);
});

The handler's response is sent when it returns one. Otherwise API routes, the ones loaded with loadApiRoutesFrom, answer with status 500 and {"message":"server_error"}, and other routes with a plain 500 error, both with Cache-Control: no-cache. In the local environment the exception is rethrown so the debug page shows it.

Responses a route returns, such as a 404 or a 422, are sent as they are.