简体   繁体   English

设置 php Zend 包含路径时遇到问题

[英]Trouble setting up php Zend include path

I am trying to set up a PHP path to my Zend Framework.我正在尝试为我的 Zend 框架设置 PHP 路径。 I am very confused on how to do this.我对如何做到这一点感到非常困惑。 My Zend Framework is located at the following location on my server:我的 Zend 框架位于我服务器上的以下位置:

amazon/ZendFramework-1.10.3-minimal亚马逊/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.我将在 amazon/ 目录中创建几个需要 Zend 框架的 php 文件。 My include path is:我的包含路径是:

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

However inside of Amazon.php is the line但是在 Amazon.php 里面是一行

require_once 'Zend/Rest/Client.php';

...and then Client.php has more dependencies set up like that, and so on. ...然后 Client.php 有更多的依赖设置,等等。

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?如何设置包含路径,以便 Amazon.php 和 Client.php(等等)可以正确引用 Zend 框架的位置?

Thanks谢谢

You will have to set your include path using set_include_path() in your Bootstrap file if you are using any.如果您正在使用任何,则必须在Bootstrap文件中使用 set_include_path() 设置包含路径。 (need to check the ZF layout for details if you are using the ZF). (如果您使用的是 ZF,则需要检查 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.当您包含 library/Zend/Loader.php 文件并调用将启用驻留在 library/Zend 文件夹中的类的自动加载的函数时,类的加载将由 Zend Loader 处理。

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

Short example in a file called bootstrap.php名为 bootstrap.php 的文件中的简短示例

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM