I am trying to use the custom error handler in slim 4, but it still seems to be using the PHP built in one, here's an output of the error.
This is what I have tried so far from here
$app->addRoutingMiddleware();
$app->addErrorMiddleware(true, true, true);
but it seems to have no effect on the error outcome, no matter what options I choose, I have also tried to use the custom renderer from the examples, but this doesn't work either.
Here is my index.php
<?php
use Illuminate\Database\Capsule\Manager as Capsule;
use Slim\Factory\AppFactory;
use Slim\Psr7\Request;
use Slim\Psr7\Response;
session_start();
require __DIR__ . '/vendor/autoload.php';
$app = AppFactory::create();
/**
* The routing middleware should be added earlier than the ErrorMiddleware
* Otherwise exceptions thrown from it will not be handled by the middleware
*/
$app->addRoutingMiddleware();
$app->addErrorMiddleware(true, true, true);
/**
* Database
*/
$capsule = new Capsule;
$capsule->addConnection([
'driver' => 'mysql',
'host' => 'mysql',
'database' => 'nuxt-auth',
'username' => 'root',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]);
// Make this Capsule instance available globally via static methods... (optional)
$capsule->setAsGlobal();
$capsule->bootEloquent();
$schema = $capsule->getDatabaseManager()->getSchemaBuilder();
/**
* Init db
*/
if (!$schema->hasTable('users')) {
$schema->create('users', function ($table) {
//TODO: write schema
});
}
$app->get('/', function (Request $request, Response $response, $args) {
$response->getBody()->write("Hello World");
return $response;
});
$app->run();