Skip to content
docsv0.24.0

ComposerAutoload

Reads the parts of an app's own `composer.json` the Make layer needs to place generated files correctly: its PSR-4 autoload map, used by {@see \Milpa\DevTools\Make\ConventionDetector} to test whether a given FQCN resolves to a real file under the app root, and by the runtime `ControllerGenerator` to find the app's primary namespace/source directory. Pure filesystem + JSON parsing — no autoloading, no `Composer\InstalledVersions` (that is {@see RootResolver}'s job; this class reads a SPECIFIC app root's manifest, not "where am I installed").

ComposerAutoload::psr4()

public static function psr4(string $root): array

The `autoload.psr-4` map declared in `$root/composer.json`, normalized to `[prefix => dir]` with the directory's trailing slash trimmed; `[]` when the file is missing, unparsable, or declares no PSR-4 autoloading.

Parameters

Parameters of psr4()
NameTypeDescription
$rootstring

ComposerAutoload::primaryNamespace()

public static function primaryNamespace(string $root): ?array

The app's primary PSR-4 namespace + source directory — the first entry in its `autoload.psr-4` map, e.g. `['App', 'src']` for `{"App\\": "src/"}`. `null` when `$root/composer.json` declares no PSR-4 autoloading at all.

Parameters

Parameters of primaryNamespace()
NameTypeDescription
$rootstring