2
I’m trying to use the autoload
of composer
and I can’t, he says the class not found
and trying to load a class from an external library.
I’ve already executed on the command line:
composer install
and
composer dump
unsuccessful.
Composer.json
"autoload": {
"psr-4":
{
"App\\":
[
"app/",
"tests/"
]
}
}
Code
<?php
namespace App\Database;
use Dotenv\Dotenv;
$dotenv = new Dotenv('../../');
$dotenv->load();
class Database
{...
Error
Fatal error: Uncaught Error: Class 'Dotenv\Dotenv' not found in /home/vagrant/Projetos/qa-toll/src/Database/Database.php on line 7
In your code where it’s loaded
vendor/autoload.php
is not described in the code?– novic
It is not clickable for the App namespaces?
– tiagopaes
it will only automatically load when on top of the
script
hadrequire 'vendor/autoload.php';
then you can use understood ... ? or thing has to give acomposer dump-autoload
for it to create the entries in the upload file.– novic
If the answer is useful accept it as a response?
– novic