Glossary

Namespace

A namespace is a code-organisation mechanism that prevents name conflicts between classes, functions, and constants. Like folders on a disk: two Logger.php files can coexist peacefully in different directories.

Declaration and usage

namespace App\Services;

class UserService { ... }

// In another file:
use App\Services\UserService;
$service = new UserService();

PSR-4 and autoloading

The PSR-4 standard maps namespaces to directory structure: App\Services\UserServiceapp/Services/UserService.php. Composer automatically loads the file on first class access — no manual require needed.