开发者

Getting Zend Framework to work with WAMP

开发者 https://www.devze.com 2023-02-08 01:55 出处:网络
Not sure what I\'m doing wrong here, all I thought I had to down was change my PHP ini settings to include_path = \".;c:\\Program Files (x86)\\WAMP\\www\\Zend\\\"

Not sure what I'm doing wrong here, all I thought I had to down was change my PHP ini settings to

include_path = ".;c:\Program Files (x86)\WAMP\www\Zend\"

But it's not working.

On my script I simply have:

require_once "Date.php";

But get the errors:

Warning: require_once(Zend/Date/DateObject.php) [function.require-once]: failed to open stream: No such file or directory in C:\Program Files (x86)\WAMP\www\Zend\Date.php on line 25

Fatal error: require_o开发者_如何学JAVAnce() [function.require]: Failed opening required 'Zend/Date/DateObject.php' (include_path='.;c:\Program Files (x86)\WAMP\www\Zend\') in C:\Program Files (x86)\WAMP\www\Zend\Date.php on line 25

Any insight in to what I am doing wrong is greatly appreciated.

Thanks.


You should not add the Zend Framework directory to the include path. You should add it's parent folder to the include path.

Thus, include_path = ".;c:\Program Files (x86)\WAMP\www\Zend\" would become include_path = ".;c:\Program Files (x86)\WAMP\www\".

After setting up your include path like this, you should use require_once 'Zend/Date.php' instead of require_once 'Date.php'. This is because there are still a lot of require calls inside the framework itself, each pointing to Zend/<classname>.


Your include path is wrong - you can either define it manually or (better) change your php.ini to add the location of your requred includes...

http://www.geeksengine.com/article/php-include-path.html

edit: these may help you

Trouble setting up php Zend include path

http://devzone.zend.com/article/4683


Everybody here suggests you add the library to your include path. I actually disagree with that. Most hosting providers does not have the ZF on a include path, and does not allow you to add it to one. So why set it up like that on your development environment; only to change it on production?

I suggest you create a library folder in your root; put the ZF in there and add that in your APPLICATION to the include path.

E.g. c:\wamp\www\library\Zend

Then for each application add the library in the index.php (you will just go one more folder up):

set_include_path(implode(PATH_SEPARATOR, array(
    realpath(dirname(__FILE__) . '/../../library'),
    get_include_path(),
)));

This allows you to easily update your ZF library. It also allows you to easily copy/svn your projects without including the ZF framework. Most people have their own style. I agree with most that you must include the library directory and not the Zend directory.


Set include path:

include_path = ".;c:\Program Files (x86)\WAMP\www\"

After:

require_once "Zend/Date.php";


You should not add the Zend/ directory to your include path but either the root of your your library folder:

If your Zend library is in www/

your include path must be: c:\Program Files (x86)\WAMP\www\

However, if ZF is in Zend/library/ it should be:

c:\Program Files (x86)\WAMP\www\Zend\library\

It is because how the file are required.

Zend_Date requires Zend/Date/DateObject from Zend/ so you need to include top level directory.

Note, that you can also use the autoloader to do the work for you if you need other Zf classes and don't want to include/require them all.

require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();

Will allow you to do $date = new Zend_Date(); without require manually any files (except Loader of course!)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号