Screening Entry Level

Explain how Composer autoloading works. What is the difference between PSR-4 and classmap autoloading, and when would you use each?

Quick Tip

Mention the optimised autoloader for production: "In deployment, we run composer dump-autoload --classmap-authoritative to eliminate filesystem checks."

What good answers include

PSR-4 maps namespace prefixes to directory paths and loads classes on demand. Classmap scans directories and builds a static map of every class. PSR-4 is standard for application code. Classmap is useful for legacy code that does not follow PSR-4 naming. In production, running composer dump-autoload --optimize generates a classmap from PSR-4 mappings for faster loading.

What interviewers are looking for

Fundamental PHP ecosystem knowledge. Developers who cannot explain autoloading likely have gaps in understanding dependency management and project structure.

← All PHP questions