shubhamc4 / zf1
Zend Framework 1 updated for PHP 8.2 compatibility
Requires
- php: ^8.2
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- vlucas/phpdotenv: ^5.6.2
Requires (Dev)
- laravel/pint: ^1.32.1
Suggests
None
Provides
None
Conflicts
None
Replaces
None
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()withmb_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 diagnosticsphp zf route:list— List and filter all registered MVC routes, URL patterns, methods, and targetsphp zf cache:clear— Flush file caches, Zend_Cache pools, and database metadata cachesphp zf serve {--port=8000}— Start the PHP built-in local development web serverphp zf make:command <Name>— Scaffold a new CLI command inapplication/Commands/php zf make:job <Name>— Scaffold a new Queue Job inapplication/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 workerphp zf queue:status— Inspect queue metricsphp zf queue:retry {id|all}— Retry failed jobsphp zf queue:failed— List failed jobsphp zf queue:flush/php zf queue:forget/php zf queue:prunephp zf schedule:run [name]— Run due scheduled tasks, or run a specific scheduled task on-demand by namephp zf schedule:list— View scheduled cron events, intervals, and namesphp zf schedule:work— Run a local daemon worker for the schedulerphp zf down/php zf up— Maintenance mode management (supports--publishto 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
.envvariables viavlucas/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/SIGINTsignals
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 jobenv($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:
- Add
#[\ReturnTypeWillChange]to any custom classes that implement PHP interfaces - Add property declarations or use
#[AllowDynamicProperties]for classes that create properties dynamically - Replace deprecated functions like
utf8_encode(),utf8_decode(),create_function(), etc. - Update string access syntax from
$string{0}to$string[0]
License
BSD-3-Clause (same as the original Zend Framework)