I'm trying to understand how to use PSR-4 with Composer. I have 3 folders in my project: folder
, folder2
and `vendor. Outside all these folders there's four files: index.php, composer.phar, composer.json and X.php. Some of these files are descibed below:
index.php
require_once 'vendor/autoload.php';
use \folder\in\A;
use \folder\in\B;
use \folder\C;
use \folder2\D;
$a = new A();
$b = new B();
$c = new C();
$d = new D();
$x = new X();
X.php
<?php
class X {
public function __construct() {
echo "Classe X";
}
}
composer.json
{
"autoload":{
"psr-4": {
"folder\\": "folder/",
"folder2\\": "folder2/"
}
}
}
The index.php file is working well for the files that are in folder and folder2, but the X.php is not being found. What's the problem? How I can found the X.php file in index.php using Composer and PSR-4? I can found the X.php file using require_once, though, but I want to know how to this with Composer and PSR-4.