This is an old revision of the document!


PHP

PSR4 Autoloading

add the following to composer.json

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

App will preface all your namespaces and src/ is your directory with files to autoload. eg:

namespace App\Util\Whatever;

Now generate autoload.php

composer dump-autoload -o

In core PHP file include autload.php

require_once('vendor/autoload.php');

Then simply give each file a namespace matching its directory and use \App\Helpers\Whatever; to load classes