Composer autoloads classes by mapping a PSR-4 namespace prefix to a directory
Answer: Composer installs PHP packages and generates an autoloader from composer.json.
What PSR-4 requires
A fully qualified class name must have a top-level vendor namespace. A namespace prefix corresponds to at least one base directory.
Claims
- id: C1 claim: Composer basic usage documents autoloading from composer.json. source: S1 evidence: "autoload"
- id: C2 claim: The same guide covers the psr-4 autoload key. source: S1 evidence: "psr-4"
- id: C3 claim: PSR-4 requires a top-level vendor namespace. source: S2 evidence: "MUST have a top-level namespace name"
- id: C4 claim: A namespace prefix corresponds to at least one base directory. source: S2 evidence: "corresponds to at least one"
Sources
- [S1] Composer basic usage. composer/composer (GitHub). https://github.com/composer/composer/blob/main/doc/01-basic-usage.md . License: MIT. Accessed 2026-11-18.
- [S2] PSR-4 Autoloader. PHP-FIG. https://www.php-fig.org/psr/psr-4/ . License: CC-BY-3.0. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: composer/composer (GitHub), Composer basic usage, MIT (https://raw.githubusercontent.com/composer/composer/main/LICENSE); PHP-FIG, PSR-4 Autoloader, CC-BY-3.0 (https://raw.githubusercontent.com/php-fig/fig-standards/master/LICENSE-CC.md). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: composer/composer (GitHub), Composer basic usage, MIT (https://raw.githubusercontent.com/composer/composer/main/LICENSE); PHP-FIG, PSR-4 Autoloader, CC-BY-3.0 (https://raw.githubusercontent.com/php-fig/fig-standards/master/LICENSE-CC.md).
Cite this
iinventedlight. 2026. "Composer autoloads classes by mapping a PSR-4 namespace prefix to a directory." iinventedlight Library, iil:note:awn25x74, version of 2026-11-18. https://iinventedlight.com/library/notes/php-composer-psr4/. License: CC-BY-4.0.
@misc{iil_note_awn25x74,
author = {{iinventedlight}},
title = {{Composer autoloads classes by mapping a PSR-4 namespace prefix to a directory}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/php-composer-psr4/},
note = {Permanent ID iil:note:awn25x74. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/php-composer-psr4.md.