views:

637

answers:

1

I have written custom resources for my Zend_Application bootstrap.

In the manual the following code is given for loading them:

$application = new Zend_Application(APPLICATION_ENV, array(
    'pluginPaths' => array(
        'My_Resource' => APPLICATION_PATH . '/resources/',
    ),
    'resources' => array(
        'FrontController' => array(
            'controllerDirectory' => APPLICATION_PATH . '/controllers',
        ),
    ),
));

This however does not make use of the application.ini which I want to use. Is there a possibility to configure this completely from my application.ini?

My final solution: (with help of Will's answer):

  • create an empty project with zf.sh create project (version 1.9.6)
  • make the following class in application/resources/Ftp.php

    class My_Resource_Ftp extends Zend_Application_Resource_ResourceAbstract 
    {
        protected $_params = array();
        public function init() {
            echo "init invoked";
            return array("hey");
        }
    }
    
  • The following application.ini

    [production]
    phpSettings.display_startup_errors = 0
    phpSettings.display_errors = 0
    includePaths.library = APPLICATION_PATH "/../library"
    bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
    bootstrap.class = "Bootstrap"
    
    
    pluginPaths.My_Resource = APPLICATION_PATH "/resources/"
    resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
    
    
    resources.ftp.username = "me"
    
    
    [staging : production]
    
    
    [testing : production]
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1
    
    
    [development : production]
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1
    
+1  A: 

Yes, you just have to use the path to your application.ini as the second argument to the constructor, e.g:

$application = new Zend_Application(
  APPLICATION_ENV,
  APPLICATION_PATH . '/config/application.ini'
);

This is the approach the quick start guide takes: http://framework.zend.com/manual/en/zend.application.quick-start.html

In your .ini file you would then add resource paths like:

pluginPaths.My_Resource = APPLICATION_PATH "/resources/"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
Will Prescott
Thanks for the answer, but it does not work. I updated my question with this try and the error.
Peter Smit
Not quite sure from the error message, will try to debug it myself later, but did notice I made a copy/paste error in my .ini file example: there shouldn't be a dot after APPLICATION_PATH in the pluginPaths line - sorry, try it without that.
Will Prescott
Now it works! Thanks a lot!
Peter Smit