PSR-4 and Directory Layout

The loader in Subsection 4.12.4 follows PSR-4, the PHP-FIG 23,464 autoloading standard every modern package uses. It maps a namespace prefix to a base directory; each further sub-namespace becomes a subdirectory and the class name plus .php the file. Matching is case-sensitive, as Linux file systems are. PSR-4 replaced PSR-0 (deprecated 21 October 2014), which also turned underscores into directories.

PSR-4 maps a class name onto a path, piece by piece
PSR-4 maps a class name onto a path, piece by piece

The package keeps Money.php, Currency.php and Exception/CurrencyMismatch.php in src/. Money is a final readonly class of an int in minor units plus a Currency backed enum; its format() uses NumberFormatter, so the package needs ext-intl. tests/ has its own prefix, Acme\ShopMoney\Tests\, and src/functions.php is loaded another way (Subsection 4.12.8). A file named currency.php works on a case-insensitive laptop and fails on Linux; in CI, composer dump-autoload -o --strict-psr reports it as not complying with PSR-4 and exits with 1.