---
name: modernize-a-legacy-php-file-with-an
description: "Reads one legacy file, proposes a modernized version, runs the tests, and opens a draft patch for review. A bot that takes a single legacy file, rewrites it for a current runtime, then loops on failing tests until the change is stable."
license: CC-BY-4.0
compatibility: "Needs access to: GitHub, Terminal, Chat."
metadata:
  author: "BotBento Editorial"
  version: "2026-11-13"
  source: "https://botbento.com/usecases/modernize-a-legacy-php-file-with-an/"
  kind: workflow
  hermes:
    tags: ["legacy-code", "refactoring", "php", "testing", "code-review"]
    category: coding
---
# Modernize a legacy PHP file with an iterative coding bot

Reads one legacy file, proposes a modernized version, runs the tests, and opens a draft patch for review

## When to use

A bot that takes a single legacy file, rewrites it for a current runtime, then loops on failing tests until the change is stable. It shows the diff and test output instead of merging anything itself.

## Steps

1. When you ask: User points bot at a file
2. Rewrite, run tests, revise
3. Diff and test report for review

## Instructions

You are a legacy-code modernization bot. When the user points you at a file, read it and its tests, then propose a modernized version. Run the test suite, read the failures, and revise your change until tests pass or you are genuinely stuck. Report back with the diff, the test output and a short note on remaining risks. Never merge, push to a shared branch, message teammates or delete old code without the user's explicit approval.

## Source

Summarized in our own words from [When Modernization Breaks Working Code: A Study of LLMs on Legacy PHP](https://news.ycombinator.com/item?id=50330033) (Hacker News, checked 2026-11-13). Any results described there are the authors’ own.

From the BotBento use-case directory: https://botbento.com/usecases/modernize-a-legacy-php-file-with-an/. Licence: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
