Problem including Zend Framework Action Helpers?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
robincanaday
Forum Newbie
Posts: 14
Joined: Thu Nov 20, 2008 12:25 am
Location: Portland Oregon USA

Problem including Zend Framework Action Helpers?

Post 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?
User avatar
turbolemon
Forum Commoner
Posts: 70
Joined: Tue Jul 14, 2009 6:45 am
Location: Preston, UK

Re: Problem including Zend Framework Action Helpers?

Post 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 :)
robincanaday
Forum Newbie
Posts: 14
Joined: Thu Nov 20, 2008 12:25 am
Location: Portland Oregon USA

Re: Problem including Zend Framework Action Helpers?

Post 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?
Post Reply