My autoload by Poser is not working

Asked

Viewed 291 times

0

I am learning to autoload using Composer, but am getting the following error while running the tests:

Fatal error: Class 'App Model Database' not found in /var/www/Library/index.php on line 5

it’s like he’s not finding the Database class, and I don’t know why, someone could help me?

Code:

Composer.json:

 {
    "autoload": {
        "psr-4": {
            "App\\" : "App/"
        }
    }
}

Database.php

<?php

namespace App\Model;

class Database
{
    ...

index php.

    <?php

use App\Model\DataBase;

$pdo = Database::conexao();
  • Related: https://answall.com/questions/213080/autoload-do-composer-n%C3%A3o-funciona

1 answer

0

I managed to solve, missed to do the include of the autoload in the index.php

require_once 'vendor/autoload.php';

Browser other questions tagged

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