0
I’m using the composer
to manage the classes of my project, in the archive composer.json
defined the folders, in the classes I put their respective namespaces
, but I can’t use them in other files.
Folder structure
Autoload
{
"require": {
"sendgrid/sendgrid": "^5.1"
},
"autoload": {
"psr-4": {
"Classes\\" : "Classes",
"DAO\\" : "DAO"
}
}
}
Class
namespace Classes;
class UsuarioLinkedin { }
}
Using the class
<?php
require_once 'vendor/autoload.php';
use Classes\UsuarioLinkedin;
$usuarioLink = new UsuarioLinkedin();
Error
Fatal error: Uncaught Error: Class 'Classes\UsuarioLinkedin' not found in C:\wamp64\www\ibico-solution\form\formLogin.php on line 58
has given the command
php composer dump-autoload
?– novic
Yes rode, the return was that Generated autoload files containing 0 classes
– Evandro Ignacio
Is there a missing configuration or something you’re not saying, where is the folder
vendor
?– novic
Sorry I ended up cutting the vendor folder of the print, but it is at the same level as the folders shown in the image
– Evandro Ignacio
change your psr-4 so:
"psr-4": {
 "Classes\\" : "Classes/",
 "DAO\\" : "DAO/"
 }
– novic
I changed it but it didn’t work
– Evandro Ignacio
I just simulated the example and in mine it worked... of course I’m not seeing your code in full, but, there is some error in the programming.
– novic
Strange file that you using the classes are at the same level as the other folders ? Or is inside one of them ?
– Evandro Ignacio
I’m using my example on the same level, it doesn’t change much if you pass the path correctly, maybe that’s your problem
– novic
Sorry way from which file?
– Evandro Ignacio
C:\wamp64\www\ibico-solution\form\formLogin.php on line 58
this do not know if this is right the file path, as it was configured, IE, your error is hard to play location.– novic