← All notes

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

Sources

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

Permanent ID: iil:note:awn25x74

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.},
}

Markdown

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.