[英]Zend Framework Include Path
我正在嘗試僅在當前項目上使用Zend Library,而無需設置php.ini
include_path(.....)
在我的index.php中,我初始化了
set_include_path('library');
Zend庫存儲在哪里。 文件夾結構如下
-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
為了解決這個問題,我將其包含在index.php中
require_once 'Zend/Db/Adapter/Adapter.php';
然后出現其他致命錯誤:
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 Aplilication
您需要設置自動加載器,以便PHP將根據需要包含類。 請參閱: http : //framework.zend.com/manual/2.3/en/modules/zend.loader.standard-autoloader.html#manual-configuration
或者,您可以使用Composer安裝ZF,這將為您解決這一問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.