YOUR DIGITAL HUB
← Back to blog

Zend 1 or Yii 1 to Symfony: migrating without a big bang

9 min read

Cover — Migrating Zend 1 or Yii 1 to Symfony

Zend 1 and Yii 1 are no longer maintained: the risk is already here

Zend Framework 1 has not been maintained by its original vendor for several years. Yii 1.1 is in maintenance mode: fixes are limited to changes that keep existing applications secure and operational. Its end of life is set for 31 December 2026, less than six weeks away. An application built on either framework therefore inherits the framework's flaws, with no official patch to apply (community forks aside).

The framework is not the only exposed layer. The application also runs on a PHP version, extensions and libraries that are ageing. A flaw found in a dependency, a compliance request or a security audit can raise the subject at any time, and almost always under pressure.

For a CIO, the useful question is not "should we migrate?" but "how long can we still operate, evolve and recruit around this code?" An unsupported framework squeezes all three margins at once.

This article does not repeat the detailed method described in our account of migrating a PHP 5.6 application to 8.3. The case is different: we are not updating the same code, we are moving from one MVC architecture to another, with different routing, data and configuration conventions. That difference changes the nature of the risk, and the way to reduce it.

Why Symfony as the target

Symfony is a common target for an application coming from Zend or Yii. The concepts are close (controllers, forms, validation, routing, dependency injection), but their implementation is more explicit, and the project publishes a readable support policy. Symfony 7.4 LTS receives security fixes until November 2029, which leaves time to amortise the migration. Target Symfony 7.4 on PHP 8.4 or 8.5. Legacy code often runs on an older PHP version, while Symfony requires PHP 8.2 or later: the two applications therefore run as separate processes, with two autoloaders and no conflict between them.

Symfony is not the only option. Choosing between two frameworks depends on the project and the team, but that choice should not obscure the more pressing issue: getting out of the current framework.

One façade, and a migration route by route

The principle is simple. A single façade receives every request and sends it to the old or the new application, depending on the URL. In practice, a reverse proxy such as Nginx or Traefik does this job:

upstream symfony { server symfony-app:8080; }
upstream legacy  { server legacy-app:8080; }

server {
    listen 443 ssl;
    # ssl_certificate, ssl_certificate_key and X-Forwarded-For omitted; configure framework.trusted_proxies in Symfony
    server_name app.example.com;

    # Routes already migrated: invoices and customers
    location ~ ^/(factures|clients)(/|$) {
        proxy_pass http://symfony;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    # Everything else is still served by the legacy code
    location / {
        proxy_pass http://legacy;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

The switch happens at the routing rule, not in the code. To roll back, you remove the rule and reload the proxy, provided schema changes remain compatible with the old code (add first, remove later). This reversibility is what makes the migration steerable: each route can be moved and moved back in minutes.

Choosing the order of routes

Start with low-risk routes: consultation, catalogue, exports, read-only pages. Then move to simple data-entry screens, and finally to flows that touch authentication, payments or batch processing. The first switches validate the infrastructure; the last ones carry the heaviest stakes, at a point when the team already knows the setup well.

Keeping the two applications consistent

Three points demand discipline during coexistence:

  • URLs. A migrated route keeps the same address, parameters, status codes and redirects. A bookmark or a link must never break because part of the application changed technology.
  • Links between applications. Pages in the legacy code that point to a migrated route must use paths the proxy can route. Centralise them in a mapping table rather than hard-coding them in templates.
  • Forms. Each framework generates and checks CSRF tokens its own way (session, cookie or form field). A form rendered by the legacy code and submitted to the new application will fail until both share the session and the token name. Handle this before the first switch, not after.

The data layer: one owner at a time

This is the point that decides success. During coexistence, both applications query the same database. The risk is not a clean outage but a silent divergence: an invoice changed on one side and read on the other under a different rule.

The rule to keep is simple: each table has one owner, the application that writes to it. The other application reads it only, ideally through a dedicated database user whose write rights have been removed. The table below summarises the steps:

Stage Who writes Who reads Schema
Mapping Legacy Legacy Inventory of tables and columns used per module
Module being migrated Legacy until the switch Both Symfony entities written from the existing schema
Migrated module Symfony Legacy, read-only Versioned Doctrine migrations
End of coexistence Symfony No legacy access Removal of obsolete columns and tables

To bootstrap the entities, write them with mapping attributes from the existing schema, then check them with doctrine:schema:validate. Exclude the legacy tables with the schema_filter option, or migrations will try to drop them. The schema reveals neither the rules applied in the code, nor columns whose meaning has drifted over time. A date stored as a string, an amount held in a float or a column repurposed for another use should be corrected during the migration, not afterwards.

Finally, schema changes happen at the moment a module is switched, not continuously. Version them with Doctrine migrations and test them on a copy of the production database. For encoding and type issues, apply the same vigilance as in the PHP 5.6 to 8.3 migration.

Sessions and authentication during coexistence

Sessions and authentication are where a poorly designed coexistence produces the most visible incidents: a user logged in on one screen and logged out on the next.

Sessions

By default, Zend Framework and Yii 1 both rely on PHP's native sessions, but each can be configured with its own storage. Check this in your code before drawing conclusions. To share a session between two applications, several settings must be aligned:

  • the same session store, for example Redis or a dedicated table;
  • the same session cookie name, with the same domain and path;
  • the same serialisation handler (php or php_serialize), set explicitly in both configurations;
  • simple values only (id, roles) in the shared session: Symfony cannot read the legacy code's serialized objects;
  • a clear convention for session keys, so that neither application overwrites the other's data.

Identity

Only one application should open the session at login, and only one should close it at logout. During coexistence, login often stays on the legacy code while the new application reads the identity from the shared session. The bridge needs a small adapter that reads the legacy session key and rebuilds the authenticated user on the Symfony side, from the same table. This is the most delicate point of the migration. Test logout in both directions: a session that survives on one side after logout on the other is a security flaw.

Legacy passwords

Old code sometimes stores passwords with a weak hash, or with a home-made algorithm. The good practice is to verify the legacy hash at login, then rewrite the password with a modern algorithm:

// Simplified example: the real logic depends on your legacy algorithm
if (verify_legacy_hash($password, $user->getLegacyHash())) {
    $user->setHash(password_hash($password, PASSWORD_DEFAULT));
    $user->setLegacyHash(null);
}

Accounts that never log in are not upgraded this way. Set a deadline, then require a password reset for accounts still on the legacy hash.

Tests before moving the code

Applications near end of support rarely have a solid test suite. Before migrating any module, freeze its current behaviour, without trying to decide first whether it is correct. This is the role of characterisation tests, described in our article on refactoring versus rewriting.

Three levels are enough to start:

  1. HTTP response tests on a representative set of URLs: status code, redirects, key elements of the content. The same set runs against the old code, then against the new.
  2. Journey tests with an automated browser on critical flows: login, data entry, validation, export.
  3. Data checks: row counts, sums and fingerprints per table, before and after a batch process.

The rule is simple: the tests must pass on the old code before they run on the new. A difference between the two reveals either a migration error or an undocumented behaviour of the legacy code. In the second case, the decision belongs to the business, not to the developer doing the migration. An implicit rule discovered at this stage costs far less than one discovered after the switch.

When a rewrite is the better choice

Coexistence is not always the best option. A rewrite by domain, without a big bang, can be preferable when:

  • the scope is small and its rules are documented or easy to reconstruct;
  • the code is so coupled that the two applications cannot share routes, sessions or data cleanly;
  • the business has changed so much that the old code is no longer a functional reference;
  • the cost of the façade, the duplicate access and the coexistence tests exceeds the cost of rebuilding the scope.

In every case, avoid a global switch. A rewrite is cut into domains, each delivered and put into production separately. The detailed decision criteria are in the article on refactoring and rewriting mentioned above.

Before you start: five decisions to make

  1. The scope and the order of routes, validated with the business teams.
  2. The owner of each table, module by module.
  3. The session and authentication strategy, with a deadline for the legacy hash.
  4. The switch criteria and the rollback procedure, route by route.
  5. The split into batches, with a budget and an acceptance step per batch, rather than a global fixed price signed on an application nobody knows well.

These decisions come before choosing a provider: they determine what you should ask for. A serious provider should be able to discuss them with you before pricing anything.

Conclusion

Migrating a framework that is out of support is first a matter of risk control, not technology. Route-by-route coexistence lets you move forward without freezing new features, provided you settle early who owns the data, how sessions work and what the rollback criteria are. Where the scope allows, a rewrite by domain remains a legitimate option.

To assess a Zend or Yii application and prepare its exit, write to us at contact@your-digital-hub.com. You can also explore our PHP expertise and our services, from scoping to operations.

Let's talk about your project. Send us the essentials.

Tell us the context, whether it is a new build, a takeover or a migration, the technologies in place and your target date.