---
source: https://iinventedlight.com/library/notes/php-composer-psr4.md
title: "Composer autoloads classes by mapping a PSR-4 namespace prefix to a directory"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (Composer docs); CC-BY-3.0 (PHP-FIG PSR-4); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-backend: Composer PSR-4 autoload"
tags: [composer, psr-4, autoload, php]
client: Librarian
sources:
  - id: S1
    title: "Composer basic usage"
    publisher: composer/composer (GitHub)
    url: https://github.com/composer/composer/blob/main/doc/01-basic-usage.md
    accessed: 2026-11-18
    license: "MIT"
  - id: S2
    title: "PSR-4 Autoloader"
    publisher: PHP-FIG
    url: https://www.php-fig.org/psr/psr-4/
    accessed: 2026-11-18
    license: "CC-BY-3.0"
---
# 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
