Php Zend框架包含路径
我正在尝试在我当前的项目中使用Zend库,而不设置php.ini的Php Zend框架包含路径,php,zend-framework2,Php,Zend Framework2,我正在尝试在我当前的项目中使用Zend库,而不设置php.ini的 include_path(.....) 在我的index.php中,我初始化了 set_include_path('library'); Zend library存储在哪里。 文件夹结构如下 -site_folder -other_folders -... -library -Zend -index.php 然后我继续初始化一个适配器 function __construc
include_path(.....)
在我的index.php中,我初始化了
set_include_path('library');
Zend library存储在哪里。
文件夹结构如下
-site_folder
-other_folders
-...
-library
-Zend
-index.php
然后我继续初始化一个适配器
function __construct()
{
$this->adapter = new Zend\Db\Adapter\Adapter(array(
'driver' => 'Pdo_Mysql',
'database' => 'database',
'username' => 'username',
'password' => 'password',
));
... other code
}
出现以下错误:
Fatal error: Class 'Zend\Db\Adapter\Adapter' not found in C:\xampp\htdocs\site_folder\index.php on line 59
Fatal error: Interface 'Zend\Db\Adapter\AdapterInterface' not found in C:\xampp\htdocs\bootSite\library\Zend\Db\Adapter\Adapter.php on line 19
为了解决这个问题,我在index.php中加入了
require_once 'Zend/Db/Adapter/Adapter.php';
然后出现其他致命错误:
Fatal error: Class 'Zend\Db\Adapter\Adapter' not found in C:\xampp\htdocs\site_folder\index.php on line 59
Fatal error: Interface 'Zend\Db\Adapter\AdapterInterface' not found in C:\xampp\htdocs\bootSite\library\Zend\Db\Adapter\Adapter.php on line 19
为了解决这个错误,我需要包括
require_once 'Zend/Db/Adapter/AdapterInterface.php';
但随后又出现了另一个错误,以此类推。如何将所有内容与index.php关联?如果不使用Zend Skeleton应用程序,您需要设置自动加载程序,以便PHP能够根据需要为您提供类。见:
或者,您可以使用Composer安装ZF,Composer将为您解决此问题。在哪里可以找到手动配置中声明的Phly和Scapi?这些只是如何为第三方库设置自动加载的示例。您只需要该代码示例中的第4、5和18行。