jemz
1
can I ask some help I can’t autoload the Class, I have this folder structure
Employee.php
namespace app\Employee;
class Employee
{
public function __construct(){
echo "hello employee";
}
}
Index.php
use app\Employee;
$emp = new Employee;
composer.json
{
"autoload": {
"psr-4": {
"Employee\\":"app/Employee"
}
}
}
In your PHP code, your namespace is “app\Employee”, not just “Employee”.
jemz
3
I change that but still I cannot load. is there another file in vendor that I will load ?
Have you included the Autoloader from the Composer vendor directory?
include_once 'vendor/autoload.php';
use app\Employee;
$emp = new Employee;
1 Like
jemz
5
wow this fixed! Thank you…
glad to be of help, happy coding
system
Closed
7
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.