在现有项目中加载 Zend 框架组件 [英] Load Zend Framework Component in Existing Project

查看:40
本文介绍了在现有项目中加载 Zend 框架组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 PHP 新手,也是 Zend Framework 的新手,所以请给我一个详细的答案.

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

我在机器上安装了 Zend Server(包括 Zend Framework)、Apache、MySql.我有一个在 Eclipse PDT(不使用 Zend Framework)中创建的项目,我决定使用 Zend_Db 在我的数据访问层中.我在这里和其他论坛上阅读了很多答案,我看到我应该使用 Zend_Loader,但我不确定如何开始.我还看到我需要一些适合我的数据库服务器类型的 php 扩展.

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.

谢谢

后期我刚刚在我的项目中复制了所需的组件并将它们包含在内,并且可以正常工作.

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

推荐答案

我最终将包含我需要的组件的 Zend 文件夹复制到名为 Library 的文件夹中,这就是我实例化 Autoloader 的方式,例如.

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();

这篇关于在现有项目中加载 Zend 框架组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆