Zend FrameworkWe’ve recently been getting requests to help upgrade the venerable Zend Framework 1 (ZF1) to newer PHP frameworks. The effort is necessary but not trivial. To help you succeed with your migration, here are some suggestions.

ZF1 Started It All

ZF1 was my choice in 2008 as I began developing larger PHP applications. The consistent structure of ZF1 was easier to maintain than the homemade frameworks I’d used before. It even explicitly supported IBM i’s Db2 database.

With the emergence of newer frameworks, such as Zend-MVC (ZF3), Zend Expressive, Laravel, and Symfony—all of which adopted newer design patterns, providing improved interoperability, standards, and often performance—ZF1 became something of an unsupported “legacy” framework.

The Need to Migrate

Why are developers migrating from ZF1 to newer frameworks?

  • ZF1 reached end-of-life in September 2016. It is no longer receiving enhancements, even for security.
  • ZF1 is incompabible with newer PHP versions, starting with PHP 7.2.
  • Less urgent but still important, newer frameworks include improvements that use newer PHP features that improve code quality and security.

Upgrade Requires Planning

Whether upgrading to one of the newer versions of Zend Framework (including Expressive), or a completely different one such as Laravel, developers will find that there is no magic bullet, no automatic upgrade path. Thinking and effort are required to determine the best approach in each case.

Examples of differences between ZF1 and newer frameworks:

  • ZF1 encouraged use of a registry component in which global data could be stored. Modern frameworks use a dependency injection container.
  • Advances in PHP, such as namespaces, rather than long class names, are reflected in the newer frameworks.
  • Changes to ZF1 components, such as the removal of decorators from the form component and removal of the navigation component, require replacement functionality.

Here’s How We Do It

  • If your ZF1 application doesn’t change frequently, you may be able to migrate in place, refactoring as you go.
  • We’ve found that if a ZF1 application is still being updated, the best approach is to create a parallel application using the new framework of your choice.
    • Run the two applications side by side. As you add controllers to the new application, create web server rewrite rules to map these routes to the newer application. In this way, you can bring functionality over to the new framework a piece at a time.
    • Take care to ensure that session data can be shared between the old and new, so that users do not have to log in twice.
    • Create the easiest routes first.
    • The effort will be more managable if most of your business logic is contained in model classes rather than in controllers.

We Can Help You Upgrade from ZF1

If your team doesn’t have the time or experience to plan and implement a migration from Zend Framework 1, talk to us about helping you plan your ZF1 upgrade. Our framework experts, including contributors to ZF and other frameworks, can help you plan a migration and even do the programming for you, if you wish. Contact us to discuss your PHP framework migration needs.