Trouble setting up php Zend include path

落爺英雄遲暮 提交于 2020-01-03 17:24:48

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/2610288/trouble-setting-up-php-zend-include-path

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