如何在Ubuntu 16.04上安装Zend Framework 1.12?指定版本安装方案
Got it, let's get Zend Framework 1.12 installed on your Ubuntu 16.04 system. The default apt-get command pulls the latest version because old 1.12 builds aren't hosted in the official Ubuntu repos anymore. Here are two reliable methods to install the specific version you need:
Composer is the standard dependency manager for PHP projects, and it's the easiest way to grab exact versions of Zend Framework 1.x.
First, install Composer if you don't have it already:
sudo apt-get update sudo apt-get install composer php-cli php-mbstring git unzipInstall Zend Framework 1.12:
- For a new project, run this command to create a project directory with ZF1.12 pre-installed:
composer create-project zendframework/zendframework1:1.12.* my-zf-project - For an existing project, create a
composer.jsonfile in your project root (if it doesn't exist) with this content:
Then run:{ "require": { "zendframework/zendframework1": "1.12.*" } }composer install - To use ZF1 in your code, just include the autoloader:
require_once 'vendor/autoload.php';
- For a new project, run this command to create a project directory with ZF1.12 pre-installed:
Note: Zend Framework 1.12 has limited compatibility with PHP 7 (the default PHP version on Ubuntu 16.04). If you hit compatibility issues, you can use a community-maintained PHP7-compatible branch by changing the Composer requirement to
zendframework/zendframework1:dev-php7.
If you prefer not to use Composer, you can manually set up ZF1.12:
Download the latest stable release of Zend Framework 1.12 (1.12.20 is the final build in this branch) from the official Zend archives, then use
wgetto pull it to your server (replace the placeholder with the actual download link):wget [Zend Framework 1.12.x tar.gz download link]Extract the archive to a system-wide PHP library directory, like
/usr/share/php:sudo tar xzf ZendFramework-1.12.20.tar.gz -C /usr/share/php sudo ln -s /usr/share/php/ZendFramework-1.12.20/library/Zend /usr/share/php/ZendUpdate your PHP include path to recognize the ZF1 library:
- For Apache, edit
/etc/php/7.0/apache2/php.ini; for CLI PHP, edit/etc/php/7.0/cli/php.ini. - Find the
include_pathline and modify it to:include_path = ".:/usr/share/php/Zend" - Restart Apache if you're using a web server:
sudo service apache2 restart
- For Apache, edit
Verify the installation by creating a test PHP file (e.g.,
test_zf.php):<?php require_once 'Zend/Version.php'; echo Zend_Version::VERSION; ?>Run it with
php test_zf.php— if it outputs1.12.20, you're good to go.
内容的提问来源于stack exchange,提问作者MrGohut

