I have my project structure like so:
src/
├─ Model/
└─ User.php
My User.php file looks like this:
<?php
namespace Bix\Model;
class User {
And my composer.json autoloader is this:
"autoload": {
"psr-4": {
"Bix\\": "src/"
}
}
Finally my bootstrap.php is this:
use Bix\Model\User;
// PSR-4 Autoloader.
require_once "vendor/autoload.php";
However if I try and create a new User()
, I get the error Fatal error: Class 'User' not found in /var/www/public/api/v1/index.php on line 8
Looking at the composer autoload_psr4.php file it looks ok:
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname(dirname($vendorDir));
return array(
'XdgBaseDir\\' => array($vendorDir . '/dnoegel/php-xdg-base-dir/src'),
'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
'KeenIO\\' => array($vendorDir . '/keen-io/keen-io/src'),
'Bix\\' => array($baseDir . '/src'),
);
Can anybody point out where I am going wrong with the above?