如何使用Zend Framework 1通过作曲家安装



最近我发现可以使用composer安装Zend Framework 1(ZF1),因此我做了A:composer require zendframework/zendframework1。通过添加以下内容来改变我的composer.json

{
  ...
  "autoload": {
    "psr-0": { "": ["application/models", "application/controllers", "application/forms"]},
    "psr-4": { "": ["src/", "library/"]}
  },
  "require": {
     ...
    "zendframework/zendframework1": "^1.12"
  }
}

运行命令composer updatecomposer dump-autoload后,我查看了作曲家生成的文件,我可以看到以下内容:

/vendor/composer/autoload_files.php
===================================
// autoload_files.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
    '92c8763cd6170fce6fcfe7e26b4e8c10' => $vendorDir . '/symfony/phpunit-bridge/bootstrap.php',
    '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
    'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
    'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
    '2c102faa651ef8ea5874edb585946bce' => $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php',
    'b067bc7112e384b61c701452d53a14a8' => $vendorDir . '/mtdowling/jmespath.php/src/JmesPath.php',
    '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
    '8a9dc1de0ca7e01f3e08231539562f61' => $vendorDir . '/aws/aws-sdk-php/src/functions.php',
    '5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php',
    '023d27dca8066ef29e6739335ea73bad' => $vendorDir . '/symfony/polyfill-php70/bootstrap.php',
    'bd9634f2d41831496de0d3dfe4c94881' => $vendorDir . '/symfony/polyfill-php56/bootstrap.php',
    '6a47392539ca2329373e0d33e1dba053' => $vendorDir . '/symfony/polyfill-intl-icu/bootstrap.php',
    '32dcc8afd4335739640db7d200c1971d' => $vendorDir . '/symfony/polyfill-apcu/bootstrap.php',
    '3a37ebac017bc098e9a86b35401e7a68' => $vendorDir . '/mongodb/mongodb/src/functions.php',
);
/vendor/composer/autoload_namespaces.php
===================================
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
    'Zend_' => array($vendorDir . '/zendframework/zendframework1/library'),
    'Twig_' => array($vendorDir . '/twig/twig/lib'),
    'SensioLabs\Security' => array($vendorDir . '/sensiolabs/security-checker'),
    'Doctrine\ORM\' => array($vendorDir . '/doctrine/orm/lib'),
    'Doctrine\DBAL\' => array($vendorDir . '/doctrine/dbal/lib'),
    'Doctrine\Common\Lexer\' => array($vendorDir . '/doctrine/lexer/lib'),
    'Doctrine\Common\Inflector\' => array($vendorDir . '/doctrine/inflector/lib'),
    'Doctrine\Common\Collections\' => array($vendorDir . '/doctrine/collections/lib'),
    '' => array($baseDir . '/application/models', $baseDir . '/application/controllers', $baseDir . '/application/forms'),
);
/vendor/composer/include_paths.php
===================================
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
    $vendorDir . '/zendframework/zendframework1/library',
);

我正在尝试使用application/bootstrap.php文件的类,例如:

use Zend_Config_Ini;
$config   = new Zend_Config_Ini('./../config/config.ini', 'general');

但是PHP抱怨以下错误:

php致命错误:未被发现的错误:在 /var/www/html/application/bootstrap.php:23

为什么?我在这里缺少什么?

是作曲家基础知识,您需要包含自动加载器文件才能加载这些类。

require __DIR__ . '/vendor/autoload.php';

相关内容

  • 没有找到相关文章

最新更新