← PHP learning pathPHP · Module 8 of 10
Object-oriented PHP
Use classes, interfaces and namespaces.
📖 Key ideas
- class User { public function __construct(private string $name) {} }
- Interfaces, abstract classes and traits.
- Namespaces organise code: namespace App\Models;
- Composer manages packages and autoloading.
- Follow PSR standards (PSR-4, PSR-12).
💡 Real-life example: Namespaces are city areas: two "Main Street" names don't clash when they're in different cities.
Constructor promotionDeclare properties in constructor
TraitReusable method set
NamespaceGroups related code
ComposerPHP package manager