Lesson 9 of 9 · 26m
Enterprise Longevity: Testing, Observability, and Upgrades
The practices that keep a Symfony codebase valuable for a decade: layered tests, logs and metrics, deprecations, dependency discipline, and calm upgrades.
The dirty secret of enterprise software is that the framework rarely kills the project. Entropy does: untested glue, ignored deprecations, mystery cron jobs, and dependencies nobody dares update. Symfony can run for a decade if your team meets its backwards-compatibility discipline halfway.
Test the pyramid you actually need
final class InvoiceApiTest extends WebTestCase
{
public function testInvoiceCannotBeReadAcrossTenants(): void
{
// authenticate, request, assert forbidden
}
}Unit tests cover domain rules, kernel tests cover wiring seams, web tests cover HTTP and security contracts, and a small number of browser tests cover critical flows. Inverting that pyramid creates a suite too slow to trust.
Logs are for incidents, not archaeology
$this->logger->warning('Payment capture failed', [
'invoice' => $invoice->publicId,
'provider' => 'stripe',
'error' => $exception->getMessage(),
]);Log identifiers and outcomes, not access tokens, card numbers, personal data, or entire request bodies. Metrics answer a different question: queue age, failed jobs, request latency, cache hit rate, and business completion rates show degradation before customers call.
Deprecations are upgrade payments due
Symfony tells you early when APIs will disappear. Run tests with deprecation reporting and ratchet the count down:
SYMFONY_DEPRECATIONS_HELPER=max[total]=0 php bin/phpunitA codebase that ignores deprecations for five years turns a routine major upgrade into a rewrite negotiation.
Dependencies and upgrades are operations
Every dependency is code you own operationally. Prefer maintained packages, review upgrades, use composer audit, and avoid packages that exist only to save thirty lines. Upgrade in small slices: PHP, Symfony, Doctrine, and authentication redesigns do not belong in the same deploy. Roll back small, not everything.
Architecture that outlives hype
Keep framework code at the edges. Controllers, commands, handlers, templates, and security config are framework-shaped; domain rules should be understandable without opening framework documentation. When the next hype cycle arrives, evaluate it against business cost rather than fear.
Field notes
- Workers and cron jobs deserve the same deployment, logging, and test discipline as web requests.
- Keep an inventory of queues, schedules, mail flows, webhooks, and buckets.
- Health checks should test dependencies shallowly; a green page that cannot reach the database is theater.
- Write replay, secret-rotation, and restore runbooks before the incident.
- Backups are untested until you have restored one.
Was this lesson helpful?