Search by

Zend Framework 1 updated for PHP 8.2 compatibility

Package info

github.com/Shubhamc4/zf1

pkg:composer/shubhamc4/zf1

Statistics

Installs: 43

Dependents: 0

Suggesters: 0

Stars: 2

Open Issues: 0

v2.0.2 2026-11-04 09:10 UTC

This package is auto-updated.

Last update: 2026-11-04 12:03:57 UTC


README

This is an updated version of the Zend Framework 1 package adapted to work with PHP 8.2.

Background

Zend Framework 1 (ZF1) officially ended its life on September 28, 2016. However, many applications still rely on it, and with PHP moving forward, compatibility issues have emerged.

This package aims to provide a PHP 8.2 compatible version of Zend Framework 1, allowing legacy applications to continue functioning on modern PHP environments.

PHP 8.2 Compatibility

This version of Zend Framework 1 has been updated to be fully compatible with PHP 8.2. Key updates include:

  • Added #[\ReturnTypeWillChange] attributes to interface implementations (Iterator, Countable, ArrayAccess, etc.)
  • Added #[AllowDynamicProperties] attribute to classes that use dynamic properties
  • Replaced deprecated utf8_encode()/utf8_decode() with mb_convert_encoding()
  • Updated string access syntax (replaced curly braces with square brackets)
  • Fixed constructor compatibility issues
  • Updated parameter default value ordering in method signatures
  • Removed usage of deprecated PHP functions and features

For more detailed information about the PHP 8.2 compatibility changes, see the PHP82_COMPATIBILITY.md file.

Installation

composer require shubhamc4/zf1

Quick Start & Scaffolding

This package provides a modern application foundation and the zf CLI tool.

To scaffold the root zf CLI runner, application Kernel, and Bootstrap in your project:

php vendor/bin/zf make:foundation

This creates:

  • ./zf (root executable CLI runner)
  • application/Kernel.php (modern application lifecycle & path management)
  • application/Bootstrap.php (extended bootstrap)

Once scaffolded, you can run commands directly using ./zf or php zf:

php zf list

Features & Modern Foundation

1. Command Line Interface (zf)

Built-in commands for queues, scheduling, scaffolding, system maintenance, and local development:

  • php zf about — Display an overview of application environment, database, storage permissions, and diagnostics
  • php zf route:list — List and filter all registered MVC routes, URL patterns, methods, and targets
  • php zf cache:clear — Flush file caches, Zend_Cache pools, and database metadata caches
  • php zf serve {--port=8000} — Start the PHP built-in local development web server
  • php zf make:command <Name> — Scaffold a new CLI command in application/Commands/
  • php zf make:job <Name> — Scaffold a new Queue Job in application/Jobs/
  • php zf queue:table — Create database tables for jobs and failed jobs (zend_jobs, zend_failed_jobs)
  • php zf queue:work — Start background queue worker
  • php zf queue:status — Inspect queue metrics
  • php zf queue:retry {id|all} — Retry failed jobs
  • php zf queue:failed — List failed jobs
  • php zf queue:flush / php zf queue:forget / php zf queue:prune
  • php zf schedule:run [name] — Run due scheduled tasks, or run a specific scheduled task on-demand by name
  • php zf schedule:list — View scheduled cron events, intervals, and names
  • php zf schedule:work — Run a local daemon worker for the scheduler
  • php zf down / php zf up — Maintenance mode management (supports --publish to publish editable maintenance view, --template= for custom views, and secret bypass tokens)
  • php zf db:backup — Automated gzip database backup with retention pruning

2. Modern Application Kernel (ZF1\Foundation\Kernel)

  • Auto-detects and loads .env variables via vlucas/phpdotenv
  • Supports both PHP array configuration files (application/configs/application.php) and traditional INI files (application/configs/application.ini)
  • Automatic project path resolution (base_path(), app_path(), storage_path(), public_path(), config_path())

3. Background Job Queue (ZF1\Queue\Queue)

  • Database-backed (zend_jobs, zend_failed_jobs) and synchronous drivers
  • Automatic job deduplication and unique payloads
  • Exponential backoff and retry limits
  • Graceful shutdown on SIGTERM / SIGINT signals

4. Cron Task Scheduler (ZF1\Schedule\Schedule)

  • Fluent scheduling syntax (->daily(), ->everyFiveMinutes(), ->weekdays())
  • Pure PHP 5-part cron parser (CronExpression)
  • Name schedules for easy tracking and manual execution:
    $schedule->command('db:backup')->name('nightly-backup')->dailyAt('02:00');
    $schedule->job(PruneLogsJob::class)->name('prune-logs')->weekly();
  • Run any scheduled task immediately on-demand by name:
    php zf schedule:run nightly-backup
  • Mutex-based overlap prevention and background execution

5. Universal Helpers

Autoloaded framework helpers available globally:

  • dispatch($job, $payload, $queue, $delay) — Quickly dispatch a background job
  • env($key, $default)
  • base_path($subpath) / app_path() / storage_path() / public_path() / config_path()
  • url($path, $params, $secure) / asset($path, $version)
  • storage($disk)
  • blank($val) / filled($val) / data_get($target, $key)
  • discord_notify($title, $message, $fields)

Requirements

  • PHP 8.2 or higher

Usage with Legacy Applications

When using this package with an existing ZF1 application, you may need to make some changes to your code to ensure compatibility with PHP 8.2:

  1. Add #[\ReturnTypeWillChange] to any custom classes that implement PHP interfaces
  2. Add property declarations or use #[AllowDynamicProperties] for classes that create properties dynamically
  3. Replace deprecated functions like utf8_encode(), utf8_decode(), create_function(), etc.
  4. Update string access syntax from $string{0} to $string[0]

License

BSD-3-Clause (same as the original Zend Framework)