简体   繁体   English

Zend框架包含路径

[英]Zend Framework Include Path

I am trying just to use Zend Library on my current project, without setting php.ini's 我正在尝试仅在当前项目上使用Zend Library,而无需设置php.ini

include_path(.....)

In my index.php i initialized 在我的index.php中,我初始化了

set_include_path('library');

Where is stored Zend library. Zend库存储在哪里。 Folder structure is following 文件夹结构如下

-site_folder
    -other_folders
    -...
    -library
         -Zend
    -index.php

Then i proceed to initialize an Adapter 然后我继续初始化适配器

function __construct()
{
    $this->adapter = new Zend\Db\Adapter\Adapter(array(
        'driver' => 'Pdo_Mysql',
        'database' => 'database',
        'username' => 'username',
        'password' => 'password',
    ));

... other code

}

And following error appears: 并出现以下错误:

Fatal error: Class 'Zend\Db\Adapter\Adapter' not found in C:\xampp\htdocs\site_folder\index.php on line 59

To solve this question i include in my index.php 为了解决这个问题,我将其包含在index.php中

require_once 'Zend/Db/Adapter/Adapter.php';

Then other fatal error appears: 然后出现其他致命错误:

Fatal error: Interface 'Zend\Db\Adapter\AdapterInterface' not found in C:\xampp\htdocs\bootSite\library\Zend\Db\Adapter\Adapter.php on line 19

To solve this error i need to include 为了解决这个错误,我需要包括

require_once 'Zend/Db/Adapter/AdapterInterface.php';

But then arise another error an so on. 但是随后又出现另一个错误等等。 How can i just related everything to my index.php? 我如何才能将所有内容都关联到index.php? Without using Zend Skeleton Apllication 不使用Zend Skeleton Aplilication

You need to setup the autoloader so that PHP will include the classes on demand for you. 您需要设置自动加载器,以便PHP将根据需要包含类。 See: http://framework.zend.com/manual/2.3/en/modules/zend.loader.standard-autoloader.html#manual-configuration 请参阅: http : //framework.zend.com/manual/2.3/en/modules/zend.loader.standard-autoloader.html#manual-configuration

Alternatively, you could install ZF using Composer, which would take care of this for you. 或者,您可以使用Composer安装ZF,这将为您解决这一问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM