EPSIA Logo
  • Back to Home
  • DE | EN

Modernisation · July 2026

PHP Modernisation 2026: From Legacy to AI-Ready in 5 Steps

Introduction: PHP in German SMEs — the Invisible Backbone

PHP powers a large share of business applications in German SMEs. Whether ERP integrations, customer portals or internal administration tools — many of these systems were developed ten or fifteen years ago and still run reliably today on PHP 5.x or 7.x. The problem: they run reliably, but they do not evolve.

When companies today want to use AI assistants such as GitHub Copilot, Cursor or Claude Code to accelerate their development, these tools fail on precisely these legacy codebases. Missing type information, monolithic architectures and outdated language constructs make it almost impossible for the AI to deliver meaningful suggestions. The result: the AI hallucinates, produces faulty code or simply does not understand the context.

The good news: PHP can be modernised step by step — without a complete rewrite. In five concrete steps you make your codebase fit for AI-assisted development.

Step 1: Update the PHP Version

The most important first step is upgrading to PHP 8.2 or higher. Many companies shy away from this step because it is considered risky. In practice, however, the upgrade is highly plannable, especially when done incrementally: first PHP 7.4 as an intermediate stage, then PHP 8.0, then 8.2+.

Why is the version so decisive for AI-readiness? Modern PHP versions bring language features that AI assistants urgently need as context information:

  • Typed Properties (from PHP 7.4): Properties of a class get explicit types. The AI immediately understands what data an object contains.
  • Union Types (from PHP 8.0): string|int instead of vague PHPDoc comments. Precise type information means more precise AI suggestions.
  • Named Arguments (from PHP 8.0): Function calls become self-documenting — the AI recognises the meaning of each parameter.
  • Enums (from PHP 8.1): Instead of magic strings or constants there are real value sets that the AI can fully grasp.
  • Readonly Properties (from PHP 8.2): Immutability becomes visible in the code — the AI knows which values it must not touch.

Through the version upgrade and the use of these features alone, the AI-Readiness Score of a codebase can improve by 20 to 30 percent — before a single line of business logic is rewritten.

Step 2: Introduce Typing Consistently

Types are the most important context an AI can extract from source code. Without types, the AI must guess what a variable contains, what a function returns and which values a parameter accepts. With types, this guessing becomes unnecessary.

Introduction happens in three stages:

  • declare(strict_types=1) in every file. This forces PHP to apply strict type checks at runtime and uncovers hidden type errors.
  • Return Types added: Every function and method gets an explicit return type. This is the single most effective step for AI readability.
  • Property Types added: All class properties get type definitions. Together with the constructor, this yields a complete picture of the data structure.

In practice we recommend starting with the most frequently used classes — typically models, services and controllers. Tools such as PHPStan at level 6 or higher help to systematically identify missing types. Every file that is fully typed is immediately better understood by AI assistants.

Step 3: Modularise the Monolith

AI assistants work with a limited context window. A 5,000-line controller is just as incomprehensible to an AI as it is to a new developer. Modularisation is therefore not only good software engineering — it is a prerequisite for effective AI use.

The proven approach is the Strangler Fig Pattern: instead of replacing the monolith in one go, new, clean modules grow around the existing code until the old code is gradually replaced.

Concretely this means:

  • Split controllers: One controller per domain instead of a „god controller“ with 50 methods. Each controller has a clear, limited responsibility.
  • Extract service classes: Business logic moves out of controllers into dedicated service classes. This separates HTTP handling from domain logic and makes both individually testable.
  • Introduce dependency injection: Instead of new calls in the business logic, dependencies are injected via the constructor. This makes classes interchangeable and testable — and gives the AI clear information about which dependencies a class has.

Every extracted module is immediately a better target for AI-assisted development: manageable, typed and with clear interfaces.

Step 4: Introduce Tests as a Safety Net

Without tests, AI-assisted development is flying blind. When an AI suggests or refactors code, you need an automated way to check whether the result is correct. Tests are that safety net.

The pragmatic starting point:

  • Set up PHPUnit: The basic configuration takes less than a day. A simple phpunit.xml and a first test are enough to establish the infrastructure.
  • Critical paths first: Do not start with 100% coverage. First test the business processes where errors would be most costly — payment processing, permission checks, data imports.
  • Coverage as a metric: Every new function gets a test. Every bug fix gets a regression test. This way coverage grows organically and purposefully.

For AI-assisted development, tests are doubly valuable: the AI can validate against the test suite, and you can verify AI-generated changes with a single command. In our projects we regularly see that a test coverage of 60 to 70 percent of the critical paths is enough to use AI assistants productively and securely.

Step 5: Create AI Context

The last step is often overlooked, but is decisive: you must explicitly tell the AI how your project is structured. Code alone is not enough — context makes the difference between usable and brilliant AI suggestions.

  • Create CLAUDE.md / COPILOT.md: A Markdown file in the project root that describes architecture, conventions, database schema and common patterns. AI assistants read this file automatically and align their suggestions accordingly.
  • Maintain API documentation: OpenAPI/Swagger specifications for all interfaces. With these, the AI can generate valid API calls without having to read the code behind the endpoint.
  • Document the architecture: A simple diagram or a text description of the module structure helps the AI to suggest changes in the right place.
  • Set up a CI/CD pipeline: Automated builds and tests give the AI (and you) immediate feedback on every change. GitHub Actions, GitLab CI or Jenkins — the specific tool is secondary.

In practice we see: teams that have a well-maintained context file achieve up to three times better results with AI assistants than teams without explicit context — on an identical codebase.

Typical Timeframe and Costs

A complete PHP modernisation is not a weekend project, but neither is it a multi-year undertaking. In practice we reckon with 4 to 12 weeks per module, depending on the size and complexity of the existing codebase.

The sequence is plannable:

  • Week 1-2: Analysis, PHP upgrade planning, setting up the test infrastructure
  • Week 3-6: Typing and initial modularisation of the most critical components
  • Week 7-10: Tests for critical paths, further modularisation
  • Week 11-12: Create AI context, set up CI/CD, train the team

Important for budget planning: modernisation projects aimed at digitalisation and AI enablement are often eligible for funding — for example through the programme „Digital Jetzt“ or state-specific digitalisation grants. We are happy to advise you on the current funding opportunities.

Conclusion: Modernisation Is the Key to AI Use

PHP legacy code is not an obstacle to AI-assisted development — provided it is systematically modernised. The five steps — version upgrade, typing, modularisation, tests and AI context — build on each other and each deliver measurable value in their own right.

You do not have to do everything at once. Each individual step improves the quality of your codebase and brings you closer to productive AI use. The most important step is the first.

Find out where your PHP project stands: Our free Quick Check analyses the current state of your codebase and shows you the concrete modernisation path.

Start the free Quick Check

© 2026 EPSIA GmbH. All rights reserved. | Imprint | Privacy Policy