Load Zend Framework Component in Existing Project

自闭症网瘾萝莉.ら 提交于 2019-12-12 06:02:21

问题


I am new to PHP and very new to Zend Framework, so please give me a detailed answer.

I have Zend Server (including Zend Framework), Apache, MySql installed on the machine. I have a project created in Eclipse PDT (not with Zend Framework) and I've decided I want to use Zend_Db in my Data Acces Layer. I read many answers here and on other forums, I saw that I should use Zend_Loader but I am not really sure how to begin. I also saw that I need some php extension appropriate to the type of my database server.

As I said, please give me a detailed answer or a kick in the right direction.

Thanks

Later edit: I've just copied the required components in my project and included them and it works.


回答1:


I ended up copying the Zend folder with the components I needed into a folder called Library and this is the way I instantiate the Autoloader, for example.

/* Define site root */
defined('DOCUMENT_ROOT') ? null : define('DOCUMENT_ROOT',realpath(dirname(__FILE__)));
defined('SITE_ROOT') ? null : define('SITE_ROOT',realpath(dirname(DOCUMENT_ROOT).'\mysite'));


$includePath[] = DOCUMENT_ROOT.'.';
$includePath[] = SITE_ROOT . '\Library';
$includePath[] = get_include_path();
$includePath = implode(PATH_SEPARATOR,$includePath);
set_include_path($includePath);

//Including Zend LoaderClass
require_once('Library/Zend/Loader/Autoloader.php');

//Loading the auto loader file.( Including the autoloader.php file)
$autoloader = Zend_Loader_Autoloader::getInstance();


来源:https://stackoverflow.com/questions/4542527/load-zend-framework-component-in-existing-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!