Skip to main content

What is autoloading (PSR-4) and how does it improve structure?

Mid PHP
Quick Answer PSR-4 is a standard that maps PHP namespaces to file system directories. Namespace prefix App maps to src/ directory, so App\Models\User loads from src/Models/User.php. Composer implements PSR-4 autoloading automatically based on composer.json configuration. This replaces manual require statements. PSR-4 makes project structure predictable and autoloading efficient.

Answer

PSR-4 maps namespaces to folders. Composer autoloading eliminates manual include calls and keeps code organized.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice