Dr Casper Black
Dr Casper Black

Reputation: 7468

Add DIR to application dir Zend Framework

I whant to use some classes that are not part of ZF. I have a dir classes in application dir and the classes dir contains classes that are required as object or static. In Bootstrap i "load" every class.php.

Zend_Loader::loadFile('TimeZones.php', APPLICATION_PATH.'/classes/', false);

How can I have all the classes by default loaded/included from this dir?


SOLUTION for now. in Bootstrap.php

$files = scandir(APPLICATION_PATH.'/classes/');

foreach($files as $file) {
    if($file[0] != '.') {
        Zend_Loader::loadFile($file, APPLICATION_PATH.'/classes', false);
    }
}

Upvotes: 0

Views: 96

Answers (2)

Derek Illchuk
Derek Illchuk

Reputation: 5658

To have your classes loaded automatically from that dir, place it in your include_path. Here's two ways to do that. Setting include_path directly in your PHP.ini, if at all possible, is recommended.

Upvotes: 0

Victor Nicollet
Victor Nicollet

Reputation: 24587

You might want to add your dir to the include_path where PHP looks for files.

set_include_path( get_include_path() . PATH_SEPARATOR . 
                  APPLICATION_PATH.'/classes/' );

Upvotes: 2

Related Questions