I am adding some custom classes to a project. I am struggling to get psr-4 autoloading to work.
I am placing my custom classes in a folder at [project root]/lib Here is the autoload bit from my composer.json:
"autoload": {
"psr-4": {
"App\\": "app/src",
"Lib\\": "lib"
}
},
I have a file P_Database.php in the lib folder with the following declarations:
<?PHP
namespace Lib;
class P_Database
{
//
I call the class in a file with:
use Lib\P_Database;
require __DIR__ . '/../vendor/autoload.php';
$db = new P_Database();
I get a 500 error:
PHP Fatal error: Class 'Lib\\P_Database' not found....
I have run composer dump-autoload. Can anyone point me in the right direction?