Lesson content
Read, practise, then check your understanding
Namespaces prevent collisions and make package ownership explicit. use imports or aliases classes, functions, and constants; it does not load files by itself.
Practical example
<?php
namespace App\Learning;
use DateTimeImmutable as DateTime;
final class Lesson { public function createdAt(): DateTime { return new DateTime(); } }
Composer generates autoloaders, commonly using PSR-4 mappings from namespace prefixes to directories. Avoid manual require chains, global namespace pollution, ambiguous aliases, and source trees that do not match their declared autoload rules.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.