I'm studying Composer and its forms of autoload (classmap, file, psr-0, psr-4), however in my example it is appearing with the following error:
Fatal error: Class 'Library\Exemplo' not found in/var/www/html/CursoPHP/composer/index.php on line 5
My example folder structure is this:
/ comp
|-- /src
|-- /Library
|-- exemplo.php
|-- /vendor
|-- index.php
My index.php:
require_once 'vendor/autoload.php';
$nome = new \Library\Exemplo();
My composer.json:
"autoload": {
"psr-4": {
"Library\": "src/Library"
}
}
My example.php:
<?php namespace Library;
class Exemplo
{
public function __construct()
{
echo 'Classe Exemplo Iniciada';
}
}
?>
With all other means of composer autoload I got success, but I can not find the error of my example using the PSR-4.