Modern PHP Engineering
Chapitre 23
23 — Annexes
23 — Annexes
Annexes PHP
Glossaire (200+ termes)
A
- Abstract class : Classe ne pouvant être instanciée directement, sert de base
- ACL : Access Control List — liste de permissions
- Aggregate : Ensemble d'objets traités comme une unité (DDD)
- AOP : Aspect-Oriented Programming
- APCu : Alternative PHP Cache — cache mémoire partagé
- Argon2 : Algorithme de hachage de mot de passe (PHP 7.2+)
- Artisan : CLI de Laravel (make, migrate, tinker, etc.)
- Assertion : Vérification de contrat en test
- Attribute (PHP 8+) : Métadonnées structurées (remplace les annotations PHPDoc)
- Autoloading : Chargement automatique des classes (Composer PSR-4)
B
- BCrypt : Algorithme de hachage par défaut de PHP
- Blade : Moteur de templates de Laravel
- Bounded Context : Contexte délimité en DDD
- Broadcasting : Diffusion d'événements en temps réel (Laravel Reverb)
C
- Carbon : Bibliothèque de dates (extension DateTime)
- Cast : Conversion de type (array, object, collection)
- CI/CD : Continuous Integration / Continuous Delivery
- CLI : Command Line Interface (php artisan, php bin/console)
- Collection : Wrapper Laravel pour les tableaux (map, filter, reduce)
- Composer : Gestionnaire de dépendances PHP
- Container : Conteneur d'injection de dépendances (PSR-11)
- Contract : Interface Laravel (couche d'abstraction)
- CORBA : Common Object Request Broker Architecture
- Covariance/Contravariance : Typage des paramètres/retours (PHP 7.4+)
- CRUD : Create, Read, Update, Delete
- CSRF : Cross-Site Request Forgery
- CSS : Cross-Site Scripting
D
- DDD : Domain-Driven Design
- DDL : Data Definition Language (CREATE, ALTER, DROP)
- Dependency Injection : Injection de dépendances (constructeur, setter)
- DML : Data Manipulation Language (SELECT, INSERT, UPDATE, DELETE)
- Doctrine : ORM PHP (Symfony)
- DTO : Data Transfer Object
- Dusk : Browser testing tool pour Laravel
E
- Eager Loading : Chargement anticipé des relations (eloquent with())
- Eloquent : ORM de Laravel (Active Record)
- Enum (PHP 8.1+) : Type énuméré (pure, backed)
- Event Sourcing : Stockage des événements comme source de vérité
- Exception : Gestion d'erreurs (try/catch/finally)
F
- Facade : Proxy statique vers un service du container Laravel
- Fiber (PHP 8.1+) : Concurrence coopérative légère
- Filament : Framework d'administration pour Laravel
- First-class Callable (PHP 8.1+) : f(...) syntaxe
- Flash : Messages temporaires en session
- Flyweight : Pattern de mutualisation d'objets
- FPM : FastCGI Process Manager
- Front Controller : Point d'entrée unique (index.php)
G
- GC : Garbage Collector (Zend Engine)
- Generics : Typage paramétré (non natif en PHP — via PHPDoc/Psalm/PHPStan)
- Guzzle : HTTP Client PHP
- GuzzleHttp : Bibliothèque cliente HTTP
H
- Heredoc : Syntaxe chaîne multi-lignes avec interpolation
- HATEOAS : Hypermedia as the Engine of Application State
- Horizon : Dashboard Laravel pour Redis queues
- HTTP : HyperText Transfer Protocol
- Hydrator : Remplissage d'objet depuis un tableau
I
- IoC : Inversion of Control
- Idempotence : Propriété idempotente (même requête = même résultat)
- Interface : Contrat d'implémentation
- Iterator : Interface de parcours d'objets
J
- JIT : Just-In-Time Compiler (PHP 8.0+)
- JSON : JavaScript Object Notation
- JWT : JSON Web Token (Laravel Sanctum, tymon/jwt-auth)
L
- Laravel : Framework PHP (Artisan, Eloquent, Blade, etc.)
- Lazy Collection : Collection à chargement différé (LazyCollection)
- Livewire : Framework full-stack Laravel (composants dynamiques sans JS)
- Listener : Écouteur d'événements
M
- Magic Methods : __get, __set, __call, __toString, __invoke, etc.
- Mailables : Classes de mail Laravel
- Makefile : Automatisation de build
- Migration : Versioning de schéma BDD
- Mock : Objet simulé en test
- Monolog : Bibliothèque de logging (PSR-3)
- MVC : Model-View-Controller
N
- Named Arguments (PHP 8+) : Passage nommé des paramètres
- Namespace : Espace de noms (PSR-4)
- Nginx : Serveur web (php-fpm)
- Notification : Système de notifications Laravel (mail, database, slack)
- Null Coalescing : ?? / ??= opérateurs
- Nullsafe : ?-> opérateur (PHP 8.0+)
O
- Octane : Serveur Laravel haute performance (RoadRunner, Swoole)
- OOP : Programmation orientée objet
- OPcache : Cache d'opcodes PHP
- OpenAPI : Spécification d'API REST (Swagger)
- ORM : Object-Relational Mapping (Eloquent, Doctrine)
P
- PDO : PHP Data Objects (abstraction BDD)
- PSR : PHP Standard Recommendations (PHP-FIG)
- Pest : Framework de test PHP moderne
- PHPUnit : Framework de test unitaire PHP (xUnit)
- PSR-4 : Autoloading standard
- PSR-7 : HTTP message interfaces
- PSR-11 : Container interface
- PSR-14 : Event dispatcher
Q
- Queue : File d'attente de tâches (Redis, Database, SQS)
- Query Builder : Constructeur de requêtes SQL
R
- Redis : Cache/file d'attente/session/store
- Readonly (PHP 8.1+) : Propriété immutable
- Repository : Pattern de persistance
- REST : Representational State Transfer
- Revolt : Bibliothèque async PHP (event loop)
- Route : Définition de chemins (web.php, api.php)
- RSA : Algorithme de chiffrement asymétrique
S
- SaaS : Software as a Service
- Sanctum : Laravel API authentication (SPA, tokens)
- Scopes : Requêtes réutilisables Eloquent (local/global)
- Semver : Semantic Versioning (MAJOR.MINOR.PATCH)
- Serialization : Conversion objet → chaîne (__serialize, __unserialize)
- Service Provider : Fournisseur de services Laravel
- SOLID : Principes OOP (S, O, L, I, D)
- Spy : Test double enregistrant les appels
- SSH : Secure Shell
- Stub : Bouchon de test
- Symfony : Framework PHP (composants réutilisables)
- Swoole : Serveur async PHP (programmé en C)
T
- TDD : Test-Driven Development
- Trait : Mécanisme de réutilisation de code horizontal
- Type Hint : Déclaration de type (paramètre, retour, propriété)
- Typed Property (PHP 7.4+) : Propriété typée
U
- UUID : Universal Unique Identifier (ramsey/uuid)
- Unit Test : Test unitaire (PHPUnit, Pest)
V
- Valet : Environnement de développement Laravel macOS
- Value Object : Objet défini par ses attributs (immutable)
- Vapor : Déploiement Laravel serverless (AWS Lambda)
- View Composers : Partage de données de vue
W
- Webhook : Callback HTTP
- WebSocket : Communication bidirectionnelle temps réel
- WhereHas : Filtrage Eloquent sur relation
X
- Xdebug : Débogueur PHP (step debug, profiling, coverage)
- XSS : Cross-Site Scripting
Y
- YAML : Yet Another Markup Language (config Symfony)
Z
- Zend Engine : Moteur d'exécution PHP (PHP 8.4 = Zend Engine 4)
Cheat Sheets
Laravel Artisan
# Génération
php artisan make:model Post -mfsc # Modèle + migration + factory + seeder + controller
php artisan make:livewire PostList # Composant Livewire
php artisan make:filament-resource Post # Ressource Filament
php artisan make:rule Uppercase # Règle de validation
# Base de données
php artisan migrate # Exécuter les migrations
php artisan migrate:fresh --seed # Reset + seed
php artisan db:seed # Seeders
php artisan db:seed --class=PostSeeder
# Cache
php artisan cache:clear
php artisan config:cache
php artisan route:cache
php artisan view:cache
# Maintenance
php artisan down # Mode maintenance
php artisan up # Retour en ligne
php artisan optimize # Optimisation
# Queues
php artisan queue:work # Worker
php artisan queue:table # Table jobs
php artisan horizon # Dashboard Horizon
Eloquent Relationships
// One-to-One
public function profile(): HasOne { return $this->hasOne(Profile::class); }
// One-to-Many
public function posts(): HasMany { return $this->hasMany(Post::class); }
// Many-to-Many
public function roles(): BelongsToMany { return $this->belongsToMany(Role::class); }
// Has-Many-Through
public function comments(): HasManyThrough { return $this->hasManyThrough(Comment::class, Post::class); }
// Polymorphic
public function image(): MorphOne { return $this->morphOne(Image::class, 'imageable'); }
public function images(): MorphMany { return $this->morphMany(Image::class, 'imageable'); }
public function tags(): MorphToMany { return $this->morphToMany(Tag::class, 'taggable'); }
PHP 8+ Features
// Named arguments
mail(to: 'user@example.com', subject: 'Hello');
// Match expression
$result = match ($status) {
200, 201 => 'OK',
404 => 'Not Found',
default => 'Unknown',
};
// Nullsafe
$city = $user?->address?->city;
// Readonly class (PHP 8.2+)
readonly class Config {
public function __construct(
public string $key,
public mixed $value,
) {}
}
// Enum
enum Status: string {
case Draft = 'draft';
case Published = 'published';
public function label(): string {
return match($this) {
self::Draft => 'Brouillon',
self::Published => 'Publié',
};
}
}
// Fiber
$fiber = new Fiber(function (): void {
Fiber::suspend('pause');
return 'resume';
});
php.ini Tuning
; Execution
max_execution_time = 30
memory_limit = 256M
; Uploads
upload_max_filesize = 64M
post_max_size = 64M
; OpCache
opcache.enable = 1
opcache.memory_consumption = 256
opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 10000
opcache.revalidate_freq = 2
opcache.jit = tracing
opcache.jit_buffer_size = 100M
; Error handling
display_errors = Off
log_errors = On
error_log = /var/log/php_errors.log
; Session
session.gc_maxlifetime = 1440
session.save_path = /tmp/sessions