Jump to content

zend autoload problem


el-sid

Recommended Posts

Hello all,

 

First, let me say that i know this is a known issue...but even after googling around, am still not able to get past this error. Any help would be REALLY appreciated.  :D

 

What im trying to do is use individual components from zend framework -  in this case, the loader class to autoload all by classes in the lib directory. my  app structure is as follows:

 

Root

  application

  lib

    vendor

      Zend

        Loader(directory with all its components inside)

        Loader.php

  web

    index.php

  bootstrap.php

 

the code in the bootstrap is as follows

 


set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lib');

require_once dirname(__FILE__) . '/lib/vendor/Zend/Loader/Autoloader.php';

$autoloader = Zend_Loader_Autoloader::getInstance();

 

when i execute this, i get:

 

Warning: require_once(Zend/Loader.php): failed to open stream: No such file or directory in /home/sydney/Projects/Merchant/lib/vendor/Zend/Loader/Autoloader.php on line 24

Fatal error: require_once(): Failed opening required 'Zend/Loader.php' (include_path='.:/usr/share/php:/home/sydney/Projects/Merchant/lib') in /home/sydney/Projects/Merchant/lib/vendor/Zend/Loader/Autoloader.php on line 24

 

 

I'm using debian lenny.

 

I know this must be a configuration issue but i just cant get my head around it. Any help is appreciated. Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/203124-zend-autoload-problem/
Share on other sites

Hello el-sid,

 

I think the problem may be with this line:

 

set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lib');

 

the Zend Framework is one more directory below where it usually is in your setup.

 

I would be inclined to add that sub folder to the include path like this:

 

set_include_path( dirname(__FILE__)  . '/lib/vendor'  . PATH_SEPARATOR .  get_include_path());

 

This this will make things right with the universe.

 

if you need access to the directory above this add it at the end, before the get_include_path()

 

Joseph Melnick

JM Web Consultants

Toronto, Ontario, Canada

 

 

Hello el-sid,

 

I think the problem may be with this line:

 

set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lib');

 

the Zend Framework is one more directory below where it usually is in your setup.

 

I would be inclined to add that sub folder to the include path like this:

 

set_include_path( dirname(__FILE__)  . '/lib/vendor'  . PATH_SEPARATOR .  get_include_path());

 

This this will make things right with the universe.

 

if you need access to the directory above this add it at the end, before the get_include_path()

 

Joseph Melnick

JM Web Consultants

Toronto, Ontario, Canada

 

Hi, thanks for the reply. you were right in that i needed to add the vendor directory and your solution worked. My intention was to try and autoload the entire lib directory as some of my classes will be located at the lib root directory. So i gather in order to autoload the entire lib directory

i would have to include another path -this time to the lib yes?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.