Think Build Implement Repeat
London, UK +44 7367 067226
WhatsApp FOLLOW f in X
PHP Development

Getting Code to Production Without Drama

Last updated:

FTP is not deployment

Copying files to a live server means partial states where some files are new and some are old, no record of what changed, and no way back except copying older files over the top.

Every production incident we have been called into that started with “we just uploaded a fix” would have been prevented by a proper deployment process.

What a process needs

  1. Code in version control, deployed from a specific commit
  2. Dependencies installed as part of deployment, not uploaded
  3. Database migrations run in a controlled order
  4. Atomic switch so the site never serves a half-deployed state
  5. A tested rollback, not a theoretical one

Environments that match

  • Same PHP version as production
  • Same database engine and version
  • Same extensions enabled
  • Configuration through environment variables, not edited files
  • Test data that resembles production in shape, not in content

“It worked on staging” is only useful if staging resembles production. Different PHP versions between the two makes the staging environment nearly worthless.

Database migrations need care

Schema changes are the part of deployment that cannot easily be rolled back. Design them to be backwards compatible where possible: add columns before using them, remove them in a later deployment.

That discipline means a rollback of code does not require a rollback of the database, which is what makes rollback practical.

Secrets belong in the environment

NeverInstead
Credentials in the repositoryEnvironment variables
Production keys on developer machinesSeparate credentials per environment
Config edited on the serverConfig from the environment
Shared loginsIndividual accounts with audit

Frequently asked questions

Do we need continuous deployment?

Not necessarily. A repeatable, documented process run manually is a large improvement over FTP and is enough for many businesses.

How do we roll back a migration?

Design them to be reversible, or make them backwards compatible so code can roll back independently. The second is usually more practical.

What about zero-downtime deployment?

Achievable with an atomic switch between releases. Worth it where any downtime has a cost.

Should developers have production access?

As few as possible, individually accounted for, with an audit trail. Shared credentials are the common failure.

Keep reading

Deploying by uploading files?

A proper process is a day of setup and it prevents the incident you have not had yet.

Book a free 30-minute call Get a project estimate WhatsApp us

Related services

What we build for problems like this one

Web DevelopmentCustom Software Development