Learning lessons

Once you've resolved an issue and restored service, what lessons can be learned to ensure the same issue doesn't happen again?

Could the issue have been caught or identified sooner, before it got to production?

Ideally, an issue would be identified in a local environment, in a CI pipeline or a staging environment.

Anything before production, but the sooner, the better.

Can you introduce more tools or automated checks?

PHP in particular has a lot of tools for linting, analysing and testing code, such as PHPStan and PHPUnit.

These can be run locally or automatically within a CI pipeline.

If the pipeline is passing, the code should be deployable.

But, if there is an issue, what needs to be added to the pipeline that would have identified it?

How can you iterate and make your development and deployment processes better and more robust?