Fatal error: Uncaught Error: Class 'maimana\App' not found -- slim3

Riry

i was following alex's how to build a shopping cart lesson and everything's working fine. but then i dont know what im doing wrong so i get this error :

Fatal error: Uncaught Error: Class 'maimana\App' not found in /Applications/MAMP/htdocs/maimana/bootstrap/app.php:13 Stack trace: #0 /Applications/MAMP/htdocs/maimana/public/index.php(3): require() #1 {main} thrown in /Applications/MAMP/htdocs/maimana/bootstrap/app.php on line 13

bootsrap/app.php :

<?php

use Respect\Validation\Validator as v;
 use maimana\App as MyApp;
 use Slim\Views\Twig;
 use Illuminate\Database\Capsule\Manager as Capsule;


 session_start();

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

 $app = new MyApp;

 $container = $app->getContainer();


 $capsule = new Capsule;

 $capsule->addConnection([
   'driver' => 'mysql',
   'host' => 'localhost',
   'database' => 'maimana',
   'username' => 'rdp46',
   'password' => 'littlelion4696',
   'charset' => 'utf8',
   'collation' => 'utf8_unicode_ci',
   'prefix' => ''
 ]);
 $capsule->setAsGlobal();
 $capsule->bootEloquent();

 require __DIR__ . '/../app/routes.php';

Myapp/App.php :

   namespace maimana;

 use DI\ContainerBuilder;
 use DI\Bridge\Slim\App as DiBridge;

 class App extends DiBridge{
   protected function configureContainer(ContainerBuilder $builder)
   {
     $builder->addDefinitions([
       'settings.displayErrorDetails' => true,
     ]);

     $builder->addDefinitions(__DIR__ . '/container.php');
   }     
 }

anyone know what's going on?

Rob Allen

Rename the Myapp directory to maimana (note case) and then update your composer.json to autoload the maimana namespace.

i.e. ensure that your composer.json has:

"autoload": {
    "psr-4": {
        "maimana\\": "maimana/"
     }
}

This assumes that the maimana directoryis in the root of your project where the composer.json file is. Once you have changed composer.json, you need to run composer dumpautoload for the changes to take effect.

This is required because there is a one to one mapping between directory name that the PHP file is in and the namespace for the class in that PHP file. As the namespace in your App.php is maimana, the directory needs to be maimana.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Fatal error: Uncaught Error: Class 'Slim\Slim' not found

Fatal error: Uncaught Error: Class "SoapClient" not found

Fatal error: Uncaught Error: Class 'Username' not found in

Namespace causing PHP Fatal error: Uncaught Error: Class Not Found error

Class is defined but Fatal error: Uncaught Error: Class not found

Composer does not recognize Class "Fatal error: Uncaught Error: "Class" Not Found"

Why Fatal error: Uncaught Error: Class 'Illuminate\Foundation\Application' not found

PHP Fatal error: Uncaught Error: Class Exception not found

PHP Fatal error: Uncaught Error: Class 'Elliptic\EC' not found

It will be displayed as Fatal error: Uncaught Error: Class 'eftec\bladeone' not found

Fatal error: Uncaught Error: Class 'Ds\Map' not found PHP

PHP Fatal error: Uncaught Error: Class 'Facebook\WebDriver\ChromeOptions' not found

PHP Fatal error: Uncaught Error: Class 'ZipArchive' not found in

Laravel - Fatal error: Uncaught Error: Class 'Auth' not found

Fatal error: Uncaught Error: Class 'App\Database' not found

Fatal error: Uncaught Error: Class 'Cache' not found in Prestashop

Fatal error: Uncaught Error: Class not found in dynamic variable namespace

PHP Fatal error: Uncaught Error: Class 'SoapClient' not found

Fatal error: Uncaught Error: Class "server\PDO" not found

Fatal error: Uncaught Error: Class 'Phalcon\Config' not found

php Fatal error: Class 'Slim' not found in

Fatal error: Class __ not found

Fatal error: Class '..' not found

Composer autoloader + slim framework - fatal error: Class 'Slim\Slim' not found?

Fatal error: Uncaught Error: Class 'SQLite3'

Fatal error: Uncaught Error: Class 'Api\WP_Error' not found in wordpress

I am facing this error "Fatal error: Uncaught Error: Class 'Zend\Uri\Uri' not found"

Autoloading - Fatal error: Uncaught Error: Class

Fatal error: Uncaught Error: Class in php loop