设置 php Zend 包含路径时遇到问题 [英] Trouble setting up php Zend include path

查看:55
本文介绍了设置 php Zend 包含路径时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的 Zend 框架设置 PHP 路径.我对如何做到这一点感到非常困惑.我的 Zend 框架位于我服务器上的以下位置:

amazon/ZendFramework-1.10.3-minimal

我将在 amazon/目录中创建几个需要 Zend 框架的 php 文件.我的包含路径是:

include("ZendFramework-1.10.3-minimal/library/Zend/Service/Amazon.php");

但是在 Amazon.php 里面是一行

require_once 'Zend/Rest/Client.php';

...然后 Client.php 有更多的依赖设置,依此类推.

如何设置我的包含路径,以便 Amazon.php 和 Client.php(等等)可以正确引用 Zend 框架的位置?

谢谢

解决方案

如果您正在使用 Bootstrap 文件,则必须使用 set_include_path() 设置包含路径.(如果您使用的是 ZF,则需要检查 ZF 布局以获取详细信息).

当您包含 library/Zend/Loader.php 文件并调用将启用驻留在 library/Zend 文件夹中的类的自动加载的函数时,类的加载将由 Zend Loader 处理.

当您设置库的包含路径时,包含 library/Zend/Loader.php 并调用 Zend_Loader::registerAutoLoad() 我相信将能够毫无问题地工作.

名为 bootstrap.php 的文件中的简短示例

set_include_path('ZendFramework-1.10.3-minimal/library/'.get_include_path());require_once('Zend/Loader.php');Zend_Loader::registerAutoload();

I am trying to set up a PHP path to my Zend Framework. I am very confused on how to do this. My Zend Framework is located at the following location on my server:

amazon/ZendFramework-1.10.3-minimal

I am going to be creating a couple of php files in the amazon/ directory that will require the Zend Framework. My include path is:

include("ZendFramework-1.10.3-minimal/library/Zend/Service/Amazon.php");

However inside of Amazon.php is the line

require_once 'Zend/Rest/Client.php';

...and then Client.php has more dependencies set up like that, and so on.

How can I set up my include path so that Amazon.php and Client.php (and so on) can correctly reference the location of the Zend Framework?

Thanks

解决方案

You will have to set your include path using set_include_path() in your Bootstrap file if you are using any. (need to check the ZF layout for details if you are using the ZF).

The Loading of the classes will be handled by the Zend Loader when you include the library/Zend/Loader.php file and calling the function that will enable the automatic loading of classes that reside in your library/Zend folder.

When you set the include path to your library, include the library/Zend/Loader.php and call Zend_Loader::registerAutoLoad() I believe will be able to work without problems.

Short example in a file called bootstrap.php

set_include_path('ZendFramework-1.10.3-minimal/library/'.get_include_path());
require_once('Zend/Loader.php');
Zend_Loader::registerAutoload();

这篇关于设置 php Zend 包含路径时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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