views:

1902

answers:

5

I get the following error messages:

Warning: include_once(Zend\Db.php) [function.include-once]: 
failed to open stream: No such file or directory in 
C:\EasyPHP3\www\VPZ\Lib\Zend_1.7.7\Loader.php on line 83    

Warning: include_once() [function.include]: 
Failed opening 'Zend\Db.php' for inclusion (include_path='VPZ/') in 
C:\EasyPHP3\www\VPZ\Lib\Zend_1.7.7\Loader.php on line 83

Warning: require_once(Zend/Exception.php) 
[function.require-once]: failed to open stream: 
No such file or directory in 
C:\EasyPHP3\www\VPZ\Lib\Zend_1.7.7\Loader.php on line 87

Fatal error: require_once() [function.require]: 
Failed opening required 'Zend/Exception.php' (include_path='VPZ/') in 
C:\EasyPHP3\www\VPZ\Lib\Zend_1.7.7\Loader.php on line 87


i want to include ZendXXX\Db.php

how to change it

A: 

Use set_include_path(). See PHP.net documentation

Example:

 set_include_path(get_include_path() . PATH_SEPARATOR . '/path/to/Zend');
carl
A: 

I usually store the framework files under a "library" folder:

  • application
  • public_html
  • library
    • Zend
    • Common
    • etc....

and then in my bootstrap file, or front controller, I add that "library" folder to the include path:

set_include_path(get_include_path() . PATH_SEPARATOR . '../library');

See also:

CMS
Can i change Zend to Zendxxx
monkey_boys
That would go against the Zend Class and File Naming Conventions... http://is.gd/pBLM
CMS
+1  A: 

create a directory (say 'lib'), and put your Zend directory in it. so your directory structure looks like this:

- application
- lib
  |- Zend
- wwwroot
  |- index.php

now you should add lib to your include path. edit your index.php file:

$includePath = array();
$includePath[] = '.';
$includePath[] = './../application';
$includePath[] = './../lib';
$includePath[] = get_include_path();
$includePath = implode(PATH_SEPARATOR,$includePath);
set_include_path($includePath);

now you have your lib in your include path. you can include all Zend components like this:

include 'Zend/Loader.php';
require_once 'Zend/Db.php';

the best way is too include Zend_Loader first and then use it to load classes. do this:

require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Db');

you can also register to autoload classes. just add this line to your code after all those before:

Zend_Loader::registerAutoLoad('Zend_Loader',true);

now you do not need to include files to call classes. just instanciate your classes:

$session = new Zend_Session_Namespace('user');

there is no need to include 'Zend/Session/Namespace.php'.

farzad
that's the way to go! if you use autoload you only have to include the loader and then you can call every class and function in the whole framework without including anything.
tharkun
A: 

The reason the other suggestions say anything about doing that, is because it's a bad move - in other words, you're doing it wrong.

You can create a subdirectory and name it Zend*xxx*, but then you have to add that to your include_path, and change it, whenever you put a newly named version up.

I'd hazard a guess, and say that you don't have a good way to test the website (so you want to lock it to a particular version of ZF), and further, that you aren't using revision control, so you want all the previous versions of code in the site-directory to be able to go back to, if you find a problem when you change the live-running code directly on the server.

Alister Bulman
A: 

project without library And including library from one location project C:\xampp\htdocs\my\application library C:\xampp\Zend\library

make changes in index.php

// Ensure library/ is on include_path set_include_path(implode(PATH_SEPARATOR,
array(realpath(APPLICATION_PATH.'/../../../Zend/library'),get_include_path(),)));