Lesson content
Read, practise, then check your understanding
Use Composer, PSR conventions, strict types, dependency injection, cohesive services, immutable values, contextual escaping, parameterized SQL, secure sessions, and explicit configuration.
Practical example
<?php
function average(array $values): float {
if ($values === []) return 0.0;
return array_sum($values) / count($values);
}
Run formatters, linters, static analysis, dependency audits, and build validation. Profile representative requests before changing code. Database query count/indexes, network calls, caching, autoloading, OPcache, and serialization often dominate micro-optimizations. Protect secrets and make logs/metrics traceable without sensitive data.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.