XIGMA Research Dynamics XIGMA Research Dynamics - 4 months ago 15
PHP Question

Class Error: Fails to Declare Class

I have a simple Php Class using composer autoload. But If Try to laod the Class I have Created It Return Error Fatal error: Class 'User' not found in C:\Users\Ilamini\Desktop\xampp\htdocs\E-learning\bootstrap\boot.php on line 11

my composer.json

"autolaod" :{
"psr-4":{
"App\\" : "app"
}
}


the class

<?php

namespace App\Models;

/**
*
*/
class User
{


}


my bootstrap

require_once INC_ROOT.'/vendor/autoload.php';
$user =new \App\Models\User;
var_dump($user);
die();


bUt if require the User Class with Php Require Class it Work.

require_once INC_ROOT.'/app/Models/User.php';

$user =new \App\Models\User;
var_dump($user);
die();


I Autoload with Composer But Is not working;

Answer

I miss spelt autoload in the psr-4 composer code. So it Should be

 "autoload" :{
            "psr-4":{
                "App\\" : "app"
            }
        }
Comments