cannot find loader.php

For programming and general questions on Zend Framework

cannot find loader.php

Postby eduard77 on Tue Jan 19, 2010 6:35 am

Is the first time when I use Zend and I am a little comfused. I have this code
require_once('Zend/Loader.php'); and this error
Warning: require_once(Zend/Loader.php) [function.require-once]: failed to open stream: No such file or directory in D:\wamp\www\phpweb20\htdocs\index.php on line 3
I tought that I didn't do something well and I tried to fine manually the file loader.php but I couldn't find it. There is no such file.
Can anyone tell me what is wrong?
eduard77
 
Posts: 5
Joined: Tue Jan 19, 2010 6:31 am

Re: cannot find loader.php

Postby tomatocms on Tue Jan 19, 2010 7:06 pm

When you use:
Code: Select all
require_once 'Zend/Loader.php'

or something like:
Code: Select all
require_once 'a_php_file.php'

PHP will try to find the file in two locations:
1) Your web directory
2) All directories defined in include_path setting of your php.ini

When works with Zend Framework, you should add the path to Zend Framework directory to include_path.
To do this, add following lines to top of your index.php file (I assume that you put Zend into myapp/lib/Zend directory and your index.php was located at myapp/index.php):
Code: Select all
set_include_path(PATH_SEPARATOR
            . dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lib' . PATH_SEPARATOR
            . get_include_path());
// Now, you can requires Zend Framework classes
require_once 'Zend/Loader.php';
Image
Nguyen Huu Phuoc, founder of TomatoCMS (based on ZF, jQuery, 960Grid)
Website: http://www.tomatocms.com
Skype: phuoc.69 - Add me on your list if you want to ask/share/discuss about TomatoCMS, Zend Framework
tomatocms
 
Posts: 65
Joined: Mon Jan 18, 2010 11:32 am

Re: cannot find loader.php

Postby eduard77 on Tue Jan 19, 2010 9:39 pm

Thank you for your answer.
I am reather new in php so please be more specific
The zend framwork is in:
c:/program files/wamp/www/webpage/include/ZendFramework-1.9.7
also the path for pear is
c:/program files/wamp/bin/php/pear
Do I need to configure the apache server also?
I included the path in php.ini also but the error is the same
Warning: require_once(Zend/Loader.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\webpage\htdocs\index.php on line 3

Fatal error: require_once() [function.require]: Failed opening required 'Zend/Loader.php' (include_path='.;C:\php5\pear') in C:\wamp\www\webpage\htdocs\index.php on line 3
eduard77
 
Posts: 5
Joined: Tue Jan 19, 2010 6:31 am

Re: cannot find loader.php

Postby tomatocms on Wed Jan 20, 2010 2:16 am

You can see that in the error:
Code: Select all
include_path='.;C:\php5\pear'

It means that Zend Framework haven't been added to include_path. So, follows my guide:
1) Create a PHP_Libs folder, this folder is used to contain all most used PHP library.
For example, C:\PHP_Libs
(Note that you shouldn't name this folder that contain spaces)

2) Put Zend Framework into this folder:
Code: Select all
C:\PHP_Libs\Zend


3) Add path to this folder in include_path. Open your php.ini and set:
Code: Select all
include_path = ".;C:\php5\pear;C:\PHP_Libs"


4) Restart Apache web server and try again. It's probably that everything have to work fine now :)
Image
Nguyen Huu Phuoc, founder of TomatoCMS (based on ZF, jQuery, 960Grid)
Website: http://www.tomatocms.com
Skype: phuoc.69 - Add me on your list if you want to ask/share/discuss about TomatoCMS, Zend Framework
tomatocms
 
Posts: 65
Joined: Mon Jan 18, 2010 11:32 am


Return to Zend Framework

Who is online

Users browsing this forum: Yahoo [Bot] and 7 guests