Page 1 of 1

Problem including Zend Framework Action Helpers?

Posted: Wed Jul 15, 2009 2:32 am
by robincanaday
I have action helper directories in these places:

/files/library/Zend/Controller/Action/Helper
/files/library/Rac/Controller/Action/Helper
/files/application/classes/Controller/Action/Helper
/files/application/classes/modules/user/classes/Controller/Action/Helper

I've added the prefixes thusly:

Code: Select all

 
$prefix = 'Rac_Controller_Action_Helper';
Zend_Controller_Action_HelperBroker::addPrefix($prefix);
    
$prefix = 'Controller_Action_Helper';
Zend_Controller_Action_HelperBroker::addPrefix($prefix);
 
I've set include paths thusly:

In Bootstrap file:

Code: Select all

$rootDir = dirname(dirname(__FILE__));
define('ROOT_DIR', $rootDir);
    
set_include_path(get_include_path() 
  . PATH_SEPARATOR . ROOT_DIR . '/application/classes'
  . PATH_SEPARATOR . ROOT_DIR . '/library');
In my extension of Zend_Controller_Action:: init():

Code: Select all

$path = ROOT_DIR . '/application/modules/'.$module.'/classes';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
This is the error I get when I try to load the standard Zend Url action helper:

Warning: include_once(Controller\Action\Helper/Url.php) [function.include-once]: failed to open stream: No such file or directory in C:\xampp\files\library\Zend\Loader\PluginLoader.php on line 375

Warning: include_once() [function.include]: Failed opening 'Controller\Action\Helper/Url.php' for inclusion (include_path='.;C:\xampp\php\pear\;C:\xampp\files/application/classes;C:\xampp\files/library;C:\xampp\files/application/modules/user/classes') in C:\xampp\files\library\Zend\Loader\PluginLoader.php on line 375


It's looking in all the correct paths and loading the actual helper just fine, but I'm still getting this error. What am I doing wrong?
I wasn't sure if it was wise to have two classes folders with the same namespace... is that screwing me up here? I just figured that the first file found was included?

Re: Problem including Zend Framework Action Helpers?

Posted: Wed Jul 15, 2009 6:58 am
by turbolemon

Code: Select all

include_once(Controller\Action\Helper[b]/[/b]Url.php)
If you look at that path carefully, you'll see why the warning is being raised. You need to use DIRECTORY_SEPARATOR constant instead of just / for cross-platform support. It's the same in your include path definitions:

Code: Select all

Warning: include_once() [function.include]: Failed opening 'Controller\Action\Helper/Url.php' for inclusion (include_path='.;C:\xampp\php\pear\;[b]C:\xampp\files/application/classes[/b];[b]C:\xampp\files/library[/b];[b]C:\xampp\files/application/modules/user/classes[/b]') in C:\xampp\files\library\Zend\Loader\PluginLoader.php on line 375
Update that code and let us know how it's getting on :)

Re: Problem including Zend Framework Action Helpers?

Posted: Wed Jul 15, 2009 10:09 am
by robincanaday
turbolemon wrote:If you look at that path carefully, you'll see why the warning is being raised. You need to use DIRECTORY_SEPARATOR constant instead of just / for cross-platform support. It's the same in your include path definitions:
Yes, I should fix that... but if it were breaking my code, wouldn't it keep EVERYTHING from loading? I'm only having troubles with my action helpers (forms and other stuff are loading from those paths just fine.) I suppose it could have something to do with how the helper broker sets up paths using prefixes?