---
id: 16841
lang: en
title: "Kiro Ports PHP Apps to Java in 8 Stages and Checks Them Against the Original"
published_at: "2026-10-29 20:00:19"
source_name: "AWS Machine Learning Blog"
source_url: "https://aws.amazon.com/blogs/machine-learning/build-a-repeatable-php-to-java-migration-engine-with-kiro/"
canonical_url: "https://news.hamidun.com/en/news/16841"
categories: ["llm", "autonomous"]
publisher: "AI News by Jemal Hamidun (news.hamidun.com)"
---

# Kiro Ports PHP Apps to Java in 8 Stages and Checks Them Against the Original

> **Краткая суть (BLUF):** Moving a legacy PHP application to Java often breaks invisible business rules: the code compiles, but customers get different answers. AWS proposed an 8-stage process for the Kiro AI environment: a scanner describes the models, judge tests send identical requests to PHP and Java, and only then is code generated. The port is considered ready when both versions return matching answers. The approach suits any migration where the old system serves as the only specification.  - The scanner reads the code as text and runs nothing - Judge tests are written before the Java code and must fail on a deliberate break - The example ports only 4 of 37 models, and no parity tests exist yet

Picture an old e-commerce application in PHP, written over the years with Laravel or Symfony. Some business rules, such as which fields to hide from the customer or how relationships between tables are counted, live not in obvious code but in Eloquent traits and XML mapping files. The team rewrites everything in Java for strict typing and predictable scaling. The code compiles without errors, yet customers suddenly get different responses. In its blog, AWS showed how to deal with this using Kiro. It is an AI development environment (IDE) where an agent works with your repository and carries out multi-step tasks under human supervision. The migration there is split into 8 stages, and readiness is determined not by a developer's feeling but by a test suite that compares the behavior of the old and new versions.

## Inventory first, translation second

The main rule of the method: until the scanner has run, no model may be read, guessed at, or translated by hand. The scanner discover-models.php is a single PHP script with no dependencies. It does not run the target code; it parses the source files as text, so it works even where the project's dependencies are not installed.

It finds models in three ways: it walks the inheritance chain up to Eloquent Model, catches the Doctrine #[ORM\Entity] attribute, and reads external *.orm.xml files. The output is a single JSON manifest with all fields, type casts, relationships, and visibility rules. The scanner does not guess at anything uncertain; it places it in a queue of flags for a human. For example, if the $fillable list is built from an expression evaluated at runtime, a clear warning appears.

## Eight stages and tests as the judge

The first stages require human expertise. Stage 0 runs the scanner and collects the inventory. Stage 1 builds a set of checks before a single line of Java is written: it sends identical request-response pairs to the PHP original and the Java port. This set must pass on working PHP and fail if deliberately broken. If the checks do not notice an introduced break, they cannot be trusted.

In stages 2 and 3, a translation rulebook (RULEBOOK.md) and a gap list (GAP_INVENTORY.md) are created and validated on typical files. Stages 4 through 8 then run mostly in automated loops:

- a Spring Boot project skeleton;
- translation of the data model into JPA entities;
- translation of the input-output layer: routes become controllers, middleware becomes filters, and validation becomes annotated DTOs (data transfer objects);
- batch conversion of business logic;
- proof of parity, meaning matching behavior, and the switchover to the new version.

Two principles govern the work. The PHP code is treated as the specification: the port is ready when the judge tests agree, or else every discrepancy is recorded as an approved change. And second: fix the loop, not the code. If the same error repeats across files, the rulebook is corrected and the code is regenerated instead of patched by hand.

## What the example showed, and its limits

The demonstration project laravel-eloquent-sample is a read-only slice of an open-source Laravel application. The models Book, Chapter, Page, and User were ported to Spring Boot 3.4.1, Java 21, Maven, and the in-memory H2 database. The correspondences are mechanical and traceable to the manifest: the PHP namespace becomes a Java package, the model becomes a JPA @Entity, the hasMany and belongsTo relationships become @OneToMany and @ManyToOne, and Eloquent scope queries become Spring Data repository methods. Care is also visible in the details: the html, markdown, and text fields are marked @JsonIgnore, because in Page they were listed in the $hidden array, while the Book description is intentionally left open.

The authors acknowledge the limitations themselves. Only 4 of the 37 models were ported, and a parity test suite was never built for this slice; the specification calls this the largest gap. In other words, the example illustrates the method but does not prove it on real production systems.

For scale there is a second path: AWS Transform, AWS's agentic service for large migrations, now integrates natively with Kiro. The same skill files (versioned Markdown packages php-to-java-migration and php-model-discovery) can be handed to it, and it will run the same method in parallel across many applications. Every fix to the rulebook made in Kiro improves the next run in AWS Transform, and vice versa. The method detects Laravel, Symfony, CodeIgniter, and plain PHP on its own, and supporting a new framework requires only adding a detection line and a reference file.

## What to take from this

Even if you do not use Kiro, the scheme applies to any migration where the old system is the only complete specification. First, mechanically describe what you have. Then build a judge and confirm that it catches breaks. Only after that generate code, and fix recurring errors in the rules. The repository is open: to experiment you need PHP 8.0+ for the scanner and Java 21 with Maven for the generated projects.

---
- **Первоисточник:** [AWS Machine Learning Blog](https://aws.amazon.com/blogs/machine-learning/build-a-repeatable-php-to-java-migration-engine-with-kiro/)
- **Каноническая ссылка:** https://news.hamidun.com/en/news/16841
- **Экосистема автора:** [Бесплатный интенсив по вайбкодингу — предзапись в Нике](https://t.me/vibecodeguidebot?start=agent_intensive_news_md) · [Nomad AI](https://nomadnet.ai) · [Telegram @jemal_hamidun](https://t.me/jemal_hamidun)
