Trouble setting up php Zend include path

10,504

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();
Share:
10,504
littleK
Author by

littleK

Updated on June 04, 2022

Comments

  • littleK
    littleK almost 2 years

    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

  • littleK
    littleK about 14 years
    The above example did the trick, thank you! Small note: remove the accidental semicolon after library/
  • Andreas
    Andreas about 14 years
    sorry about that...just trying to get it right fast...good to know it helped you.
  • jduncanator
    jduncanator over 10 years
    The semicolon is actually needed, and you should be appending your include_path to the end, not the start.