Classes of autoload Composer do not work

Asked

Viewed 105 times

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

inserir a descrição da imagem aqui

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?

  • Yes rode, the return was that Generated autoload files containing 0 classes

  • Is there a missing configuration or something you’re not saying, where is the folder vendor ?

  • 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

  • change your psr-4 so: "psr-4": {&#xA; "Classes\\" : "Classes/",&#xA; "DAO\\" : "DAO/"&#xA; }

  • I changed it but it didn’t work

  • 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.

  • Strange file that you using the classes are at the same level as the other folders ? Or is inside one of them ?

  • 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

  • Sorry way from which file?

  • 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.

Show 6 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.