I am trying to understand the autoloading part with composer. Attached image is my project structure.
index.php
require __DIR__ . '/vendor/autoload.php';
// require "app/Controller/MyController.php"; // If i uncomment this my code is working fine. (only for testing purpose)
$mynamespace = new App\Controller\MyController();
$mynamespace->index();
composer.json
"psr-4": {
"App\\": "app/"
}
MyController.php
namespace App\Controller;
class MyController{
public function index(){
echo "New World";
}
}
I ran composer dump-autoload and the file is not loaded.
How to map the autoloaded file via composer? I might go with multiple folders and files. So i prefer it to be one single directory as app/
MyController.php
file look like? – cmorrisseycomposer install
? – cmorrissey