404 Error, Uncaught Error: Class "App\\AbstractResource" not found in

28 Views Asked by At

I updated Slim to version 4. I had to, because I was getting a critical error.

Issue #1: In the console client I have a 504 error, and in the server console Type: Slim: SlimNotFoundException - Not Found. 404.

My index.php code looks like this:


use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;

$resource = new \App\AbstractResource();

require __DIR__ . '/../vendor/autoload.php';


$app = AppFactory::create();

$app->addRoutingMiddleware();

/**
 * Add Error Handling Middleware
 *
 * @param bool $displayErrorDetails -> Should be set to false in production
 * @param bool $logErrors -> Parameter is passed to the default ErrorHandler
 * @param bool $logErrorDetails -> Display error details in error log
 * which can be replaced by a callable of your choice.
 
 * Note: This middleware should be added last. It will not handle any exceptions/errors
 * for middleware added after it.
 */

$errorMiddleware = $app->addErrorMiddleware(true, true, true);


// Run app


$app->get('/people(/(:id)(/))', function($id = null) use ($app, $resource) {
    $result = !empty($id) ? $resource->getOneBy('App\Entity\Person', $app, array('id' => $id)) : $resource->getAll('App\Entity\Person', $app);
    echo $result;
});

$app->post('/search(/)', function() use ($app, $resource) {
    $regNo = $app->request()->post('searchString');
    echo $resource->getOneBy('App\Entity\Person', $app, array('regNo' => $regNo, 'status' => 1));
});



$app->run();

?>

The above index.php is located in /page/api/src.

AbstractResource is located in /page/api/src/App

Composer.json specifies:

"autoload": { "psr-4": { "app": "/src" } }

For any help I am grateful, very grateful.

What can I do? Please, help.

0

There are 0 best solutions below