A running PHP application documents itself, in a way. When you take over an application without documentation, the task is to gather that scattered knowledge and write it down.
Where is the knowledge about an application when there are no docs?
- In the code: Routes, controllers, models and configuration show what the application does.
- In the version history: Commit messages and changes explain why something was built the way it was.
- In the database: Tables, relationships and data volumes show what is actually used.
- On the server: Cron jobs, web server configuration, environment variables and logs show what runs in the background.
- With your people: Whoever works with the application every day knows the workflows, special cases and known quirks.
How much can be recovered from a running system without documentation is shown by a Unique-P project in which the old CMS offered neither an API nor direct database access. A custom-built scraper captured the entire website with thousands of pages, including hierarchy, media and translations, and transferred it to TYPO3 fully automatically: automated CMS migration to TYPO3.
How an undocumented PHP application becomes manageable in five steps
- Create an inventory. PHP version, framework and its version, dependencies according to
composer.jsonandcomposer.lock, database, server, external services. The result is a list that shows you what you’re dealing with. - Set up a working copy. The application runs in a test environment with the same PHP version as in production, where its behavior can be examined without risk. Personal data there is anonymized, so the test environment also stays unproblematic under the Swiss Federal Act on Data Protection (FADP).
- Map entry points and data flows. Which pages and interfaces exist, which cron jobs and queues run, which data flows from where to where? This shows everything a change can affect.
- Secure critical workflows with tests. Characterization tests record how ordering, login or data import behave today. From then on, every unintended change shows up immediately. How such a before-and-after comparison works in a PHP upgrade is covered in the article PHP upgrade without tests.
- Let the documentation grow along the way. Everything the inventory, test environment, data flows and tests bring to light ends up in the repository. That way, the documentation isn’t created as an extra project but as a by-product of the work.
What documentation does an application need after a takeover?
| Document | Contents | For whom |
|---|---|---|
| README | Setup, running locally, key commands | Anyone who works on the code |
| Operations manual | Deployment, backups, cron jobs, monitoring, emergency procedure | Operations and support |
| Interface overview | External services, data flows, access (without passwords) | Development and the business department |
| Architecture overview | Structure, main components, known weaknesses | Development and decision-makers |
| Decision log | Why something was built or changed the way it was | Everyone who makes decisions later |
The decision log follows Michael Nygard’s idea of Architecture Decision Records: short, dated entries that record which decision was made and why.
How do you keep your application from ending up without documentation again?
The real problem of an undocumented application isn’t the missing documentation, but the dependence on a single person. That’s why, after a takeover by Unique-P, code and documentation live in your company’s repository, and all credentials in a shared password vault. That way, someone else can take over at any time, even without me.
With ongoing maintenance from Unique-P, the documentation of a taken-over application grows with every change instead of going stale again. The web application takeover page shows how to get started. What else matters with a half-finished project or AI-generated code is covered in the article taking over an unfinished project.
Sources
- [1]Characterization test · Wikipedia
- [2]Documenting Architecture Decisions · Michael Nygard, Cognitect, 2011
- [3]Bus-Faktor · Wikipedia
- [4]Bundesgesetz über den Datenschutz (DSG) · Fedlex, Schweizerische Eidgenossenschaft