Hello all,
I am trying to understand the concept of autoloading using core PHP, not any framework.
I have a file named Donor.php which is under App -> src -> Contacts.
Here is the code of Donor.php
<?php namespace src\Contacts;
class Donor{
public function __construct()
{
return ('Loaded');
}
}
I have another file named namespace.php, which is immediate child of the root directory.
The code of namespace.php looks like this.
<?php
use src\Contacts;
new \app\Contacts\Donor;
My composer.json file looks like this.
{
"autoload": {
"psr-4":{
"app\\" : "app/src"
}
}
}
Here is my full folder structure.
basic
app
src
Billing
Contacts
Donor.php
vendor
composer.json
namespace.php
Now wehenver i run namespace.php it always gives Fatal error: Class 'app\Contacts\Donor' not found in C:\xampp\htdocs\basic\namespace.php on line 5
Can anyone explain me what i am doing wrong here?