Article

Adding Composer to a Zend Framework 1 Project

Adopt Composer for application autoloading and third-party packages without pretending ZF1 is a modern laminas-migration candidate.

Composer can still help ZF1 maintainers: autoload your namespaces, pull maintained utilities, and express PHP platform constraints. That is different from claiming ZF1 is on the official Laminas migrate path.

// MODERN composer.json excerpt for app code beside vendored ZF1
{
  "name": "acme/legacy-zf1-app",
  "require": {
    "php": "^7.4"
  },
  "autoload": {
    "psr-0": {
      "MyCompany_": "library/"
    }
  },
  "config": {
    "platform": {
      "php": "7.4.33"
    }
  }
}
// LEGACY — rely only on include_path / Zend Studio
require_once 'MyCompany/Service/Billing.php';

// MODERN — Composer autoload in public/index.php before bootstrap
require dirname(__DIR__) . '/vendor/autoload.php';

Rules of engagement

  • Pin config.platform.php to the runtime you actually run—verify with platform checker.
  • Prefer maintained packages; read legacy Composer dependencies.
  • Do not install laminas/laminas-migration into this project expecting ZF1 conversion.

More: ZF1 and PHP 8, Composer autoload class not found.

Related tools

Related reading