2009年2月28日星期六

[fw-mvc] Using custom router. Where exactly?

Where exactly do you place the router? In the bootstrap file? in the index? How can you make a custom router for each module you have? Examples will be highly appreciated.

--
Vincent Gabriel.
Lead Developer, Senior Support.
Zend Certified Engineer.




Re: [fw-mvc] Proper use of Zend_Loader_Autoloader_Resource

-- Cristian Bichis <contact@zftutorials.com> wrote
(on Saturday, 28 February 2009, 10:35 PM +0200):
> Matthew Weier O'Phinney wrote:
>
>
>
> No -- but it does reflect that the proposal needs to be updated. :)
> There is a better example in the example.php file inside DASPRiD's user
> branch.
>
>
> Yes, but it's only the index.php ;) Not the bootstrapper code...
>
> http://framework.zend.com/svn/framework/standard/branches/user/dasprid/
> Zend_Application/
>
> I checked for documentation, got some questions:
>
> 1.This component MUST allow setting the application include_path (aka library)
>
> How could be set this ?

By providing the "includePaths" key (case insensitive) in the options
passed to the Zend_Application constructor:

$app = new Zend_Application(APPLICATION_ENV, array(
'includePaths' => array(
'.',
dirname(__FILE__) . '/library',
),
));

Alternately, specify an "includePaths" key in a config file passed to
the Zend_Application constructor.

> 2. What are the minimal include path to be done into index.php (so not through
> Zend_App). Just
>
> set_include_path(
> BASE_PATH . '/library' . PATH_SEPARATOR
> . get_include_path()
> );

Assuming BASE_PATH is the directory above public/, that's the basics.

> 3. How is gonna be used zend_app to give same effect as resource autoloader and
> autoloader code from below:
>
> require 'Zend/Loader/Autoloader.php';
> require 'Zend/Loader/Autoloader/Resource.php';
>
> Zend_Loader_Autoloader::getInstance()->registerNamespace('X');
>
> $loader = new Zend_Loader_Autoloader_Resource(array(
> 'namespace' => 'Default_',
> 'basePath' => MODULE_PATH . '/default'
> ));
>
> $loader->addResourceType('Model', 'models', 'Model');

There are two things going on here, and they are separate. By default,
Zend_Loader_Autoloader will be registered when Zend_Application is
instantiated. You can specify namespaces with the 'autoloaderNamespaces'
configuration key (again, case insensitive); this should be an array of
namespaces. As an example:

$app = new Zend_Application(APPLICATION_ENV, array(
'autoloaderNamespaces' => array(
'Imagis_',
'Phly_',
),
));

Resource autoloading is different. It would be handled in one of two
places: an initializer in your bootstrap, or via the "modules" bootstrap
resource. This latter will (eventually) initialize a
Zend_Application_Module_Autoloader instance (this is a concrete instance
of Zend_Loader_Autoloader_Resource that has resources defined per the
recommended directory structure) per module in your application, and, if
a bootstrap class is available for that module, register it with that
bootstrap.

I say eventually, as neither Ben nor I have put together this last bit
of functionality in the Modules resource yet.

> 4. How could be set the "php.ini settings to initialize" ?

By passing a set of key/value pairs to the "phpSettings" key when
instantiating Zend_Application:

$app = new Zend_Application(APPLICATION_ENV, array(
'phpSettings' => array(
'display_errors' => true,
'error_reporting' => E_ALL | E_STRICT,
),
));

Regarding the settings in questions 1, 3, and 4, these could be in a
config file as well, and you could simply pass the path to a config file
when instantiating Zend_Application. As an example, consider this:

$app = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/site.ini'
);

where APPLICATION_PATH . '/configs/site.ini' reads as follows:

[production]
phpSettings.display_errors = false
phpSettings.error_reporting = 771
autoloaderNamespaces.imagis = "Imagis_"
autoloaderNamespaces.phly = "Phly_"
includePaths.cwd = "."
includePaths.lib = APPLICATION_PATH "/../library"

[development : production]
phpSettings.display_errors = true
phpSettings.error_reporting = 8191

As you can see, this makes the application code simpler, and makes it
easier to switch settings per environment (which is also one of the
goals of Zend_Application).

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

Re: [fw-mvc] Proper use of Zend_Loader_Autoloader_Resource

-- Cristian Bichis <contact@zftutorials.com> wrote
(on Saturday, 28 February 2009, 10:03 PM +0200):
> Thanks, works now.
>
> What is probably missing now is an up to date documentation online, so we don't
> "waste" your time with non-bugs :)

This is why it's in the incubator. ;)


> Matthew Weier O'Phinney wrote:
>
> -- Cristian Bichis <contact@zftutorials.com> wrote
> (on Saturday, 28 February 2009, 12:36 PM +0200):
>
>
>
>
> The problem is above -- the basePath should be a path _inside_ a given
> module, not a path *to* the modules (which is how you've defined
> MODULE_PATH). Change the above to:
>
> 'basePath' => MODULE_PATH . '/default'
>
> and you should be fine.
>
>
>
> $loader->addResourceType('Model', 'models', 'Model');
> $plugins = new Default_Model_Plugins();
> ................................................
>
> I can't think to any change on bootstrap or index to led me to same error
> again... Which error was trapped by Zend_Loader::registerAutoload(), now gone.
>
> I am using now latest from SVN.
>
>
> --
> Best regards,
> Cristian Bichis
> www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com
>
>
> -- Cristian Bichis <contact@zftutorials.com> wrote
> (on Friday, 27 February 2009, 10:24 AM +0200):
>
>
> I tried last days to get in touch with some newer (or TBA) features of ZF. One
> of them is Zend_Loader_Autoloader_Resource.
>
> I made a sample for a modular archtecture. I am trying as a demonstration to
> load a Plugins model from /application/modules/default/models
>
> That's into application/Bootstrap.php:
>
> Zend_Loader::registerAutoload();
>
> $autoloader = new Zend_Loader_Autoloader_Resource(
> array(
> 'namespace' => 'Default',
> 'basePath' => MODULE_PATH
> )
> );
>
> $autoloader->addResourceTypes(array(
> 'Model' => array('path' => 'models', 'namespace' => 'Model'),
> 'DbTable' => array('path' => 'models/DbTable', 'namespace' =>
> 'DbTable')
> ));
>
>
> Okay, two things here. First, if you're going to use the Resource
> autoloader, don't uses Zend_Loader::registerAutoload(); use
> Zend_Loader_Autoloader -- and the latter is implicit when you
> instantiate the resource autoloader.
>
> Second, based on the resource types you're defining, you probably want
> to use the Zend_Application_Module_Autoloader variant, as it has all of
> the resources you indicated above defined already.
>
> In the end, it would look like this:
>
> $autoloader = new Zend_Application_Module_Autoloader(array(
> 'namespace' => 'Default_',
> 'basePath' => MODULE_PATH,
> ));
>
> and that's it.
>
>
>
>
>
>
>
>
> --
> Best regards,
> Cristian Bichis
> www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com
>

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

Re: [fw-mvc] Proper use of Zend_Loader_Autoloader_Resource

Matthew Weier O'Phinney wrote:

No -- but it does reflect that the proposal needs to be updated. :) There is a better example in the example.php file inside DASPRiD's user branch.    
Yes, but it's only the index.php ;) Not the bootstrapper code...

http://framework.zend.com/svn/framework/standard/branches/user/dasprid/Zend_Application/

I checked for documentation, got some questions:

1.This component MUST allow setting the application include_path (aka library)

How could be set this ?

2. What are the minimal include path to be done into index.php (so not through Zend_App). Just

    set_include_path(
        BASE_PATH . '/library' . PATH_SEPARATOR
        . get_include_path()
    );

3. How is gonna be used zend_app to give same effect as resource autoloader and autoloader code from below:

        require 'Zend/Loader/Autoloader.php';
        require 'Zend/Loader/Autoloader/Resource.php';
       
        Zend_Loader_Autoloader::getInstance()->registerNamespace('X');
       
        $loader = new Zend_Loader_Autoloader_Resource(array(
             'namespace' => 'Default_',
             'basePath'  => MODULE_PATH . '/default'
        ));
       
        $loader->addResourceType('Model', 'models', 'Model');

4. How could be set the "php.ini settings to initialize" ?

--  Best regards, Cristian Bichis www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com

Re: [fw-mvc] Proper use of Zend_Loader_Autoloader_Resource

Thanks, works now.

What is probably missing now is an up to date documentation online, so we don't "waste" your time with non-bugs :)

Cristian

Matthew Weier O'Phinney wrote:
-- Cristian Bichis <contact@zftutorials.com> wrote (on Saturday, 28 February 2009, 12:36 PM +0200):   
     
 The problem is above -- the basePath should be a path _inside_ a given module, not a path *to* the modules (which is how you've defined MODULE_PATH). Change the above to:      'basePath' => MODULE_PATH . '/default'  and you should be fine.    
        $loader->addResourceType('Model', 'models', 'Model');         $plugins = new Default_Model_Plugins();        ................................................  I can't think to any change on bootstrap or index to led me to same error again... Which error was trapped by Zend_Loader::registerAutoload(), now gone.  I am using now latest from SVN.   -- Best regards, Cristian Bichis www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com       -- Cristian Bichis <contact@zftutorials.com> wrote     (on Friday, 27 February 2009, 10:24 AM +0200):           I tried last days to get in touch with some newer (or TBA) features of ZF. One         of them is Zend_Loader_Autoloader_Resource.          I made a sample for a modular archtecture. I am trying as a demonstration to         load a Plugins model from /application/modules/default/models          That's into application/Bootstrap.php:                  Zend_Loader::registerAutoload();                  $autoloader = new Zend_Loader_Autoloader_Resource(                     array(                     'namespace'   => 'Default',                     'basePath' => MODULE_PATH                     )                 );                  $autoloader->addResourceTypes(array(                         'Model' => array('path' => 'models', 'namespace' => 'Model'),                         'DbTable'  => array('path' => 'models/DbTable', 'namespace' =>         'DbTable')                 ));       Okay, two things here. First, if you're going to use the Resource     autoloader, don't uses Zend_Loader::registerAutoload(); use     Zend_Loader_Autoloader -- and the latter is implicit when you     instantiate the resource autoloader.      Second, based on the resource types you're defining, you probably want     to use the Zend_Application_Module_Autoloader variant, as it has all of     the resources you indicated above defined already.      In the end, it would look like this:          $autoloader = new Zend_Application_Module_Autoloader(array(             'namespace' => 'Default_',             'basePath'  => MODULE_PATH,         ));      and that's it.       
   


--  Best regards, Cristian Bichis www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com

Re: [fw-mvc] Proper use of Zend_Loader_Autoloader_Resource

-- keith Pope <mute.pop3@googlemail.com> wrote
(on Saturday, 28 February 2009, 03:08 PM +0000):
> Ah this is why it didnt work for me :)
>
> Should the methods be private or public in the bootstrap file?

The various initializer resources need only be prefixed with '_' -- they
*should* be protected or private, to ensure that they may only be called
via bootstrap() or __call(). The rationale behind this is twofold:

* Consistency of interface. While you can define _init*() methods in
your class, we're also allowing use of resource plugins (you can see
some of these in the Zend/Application/Resource/ tree). To have a
consistent interface for both resource plugins and internal
initializers, we have defined the bootstrap() and __call() methods.

* Dependency tracking. One of the "rules" for Zend_Application is that
any given resource/initializer may be run only once. However,
certain resources/initializers may depend on others. The bootstrap()
method keeps track of which ones have been run, and returns early
when a requested resource/initializer has been run previously.


> 2009/2/28 Matthew Weier O'Phinney <matthew@zend.com>:
> > -- Cristian Bichis <contact@zftutorials.com> wrote
> > (on Saturday, 28 February 2009, 11:49 AM +0200):
> >> Ok, i put up a sample based on http://framework.zend.com/wiki/display/ZFPROP/
> >> Zend_Application+-+Ben+Scholzen
> >>
> >> I don't get the error i encountered before, but i get a new one.
> >>
> >> //index.php
> >> <?php
> >>     if( !defined('APPLICATION_ENVIRONMENT'))
> >>         define('APPLICATION_ENVIRONMENT', 'production');
> >>
> >>     define('PUBLIC_PATH', realpath(dirname(__FILE__)));
> >>     define('BASE_PATH', realpath(dirname(dirname(__FILE__))));
> >>     define('APPLICATION_PATH', BASE_PATH . '/application');
> >>     define('MODULE_PATH', APPLICATION_PATH . '/modules');
> >>
> >>     set_include_path(
> >>         BASE_PATH . '/library/dasprid' . PATH_SEPARATOR
> >>         .BASE_PATH . '/library/incubator' . PATH_SEPARATOR
> >>         .BASE_PATH . '/library' . PATH_SEPARATOR
> >>         . get_include_path()
> >>     );
> >>
> >>     require 'Zend/Application.php';
> >>
> >>     $application = new Zend_Application(APPLICATION_ENVIRONMENT, array(
> >>         'autoloaderNamespaces' => array(
> >>             'Imagis',
> >>         ),
> >>         'bootstrap' => APPLICATION_PATH . '/Bootstrap.php'
> >>     ));
> >>
> >>     $application->bootstrap();
> >>
> >>     Zend_Controller_Front::getInstance()->dispatch();
> >> ?>
> >>
> >> //Bootstrap.php based on http://framework.zend.com/wiki/display/ZFPROP/
> >> Zend_Application+-+Ben+Scholzen
> >> <?php
> >>
> >> require_once 'Zend/Application/Bootstrap/Base.php';
> >>
> >> class Bootstrap extends Zend_Application_Bootstrap_Base
> >> {
> >>     public $front;
> >>
> >>     public function init()
> >>     {
> >>         $this->front = Zend_Controller_Front::getInstance();
> >>     }
> >>
> >>     public function run()
> >>     {
> >>         $this->front->dispatch();
> >>     }
> >>
> >>     protected function _initControllers()
> >>     {
> >>         //$this->front->setControllerDirectory(APPLICATION_PATH . '/
> >> controllers', 'default');
> >>         $this->front->addModuleDirectory(MODULE_PATH . '/modules');
> >>         return $this;
> >>     }
> >>
> >>     protected function _initRequest()
> >>     {
> >>         $this->request = new Zend_Controller_Request_Http;
> >>         $this->front->setRequest($this->request);
> >>         return $this;
> >>     }
> >> }
> >>
> >>
> >> And the error is: Fatal error: Call to a member function addModuleDirectory()
> >> on a non-object in D:\_Work\site\application\Bootstrap.php on line 22
> >>
> >>
> >> Might be something i configured incorrectly.
> >
> > No -- but it does reflect that the proposal needs to be updated. :)
> > There is a better example in the example.php file inside DASPRiD's user
> > branch.
> >
> > Basically, your index.php looks good -- it's your Bootstrap class that
> > isn't working correctly here, and it's due to some conventions that have
> > changed as part of the proposal evaluation.
> >
> > First off, there is no init() method. This is offset by the fact that,
> > instead, you can now do dependency checking in your initializers. As
> > an example, try the following Bootstrap:
> >
> >    class Bootstrap extends Zend_Application_Bootstrap_Base
> >    {
> >        public function _initFrontController()
> >        {
> >            $this->front = Zend_Controller_Front::getInstance();
> >        }
> >
> >
> >        protected function _initControllers()
> >        {
> >            // runs _initFrontController() if not already run:
> >            $this->bootstrapFrontController();
> >
> >            $this->front->addModuleDirectory(MODULE_PATH . '/modules');
> >        }
> >
> >        protected function _initRequest()
> >        {
> >            // runs _initFrontController() if not already run:
> >            $this->bootstrapFrontController();
> >
> >            $this->request = new Zend_Controller_Request_Http;
> >            $this->front->setRequest($this->request);
> >        }
> >
> >        public function run()
> >        {
> >            $this->front->dispatch();
> >        }
> >     }
> >
> > Note the calls to "bootstrapFrontController()" -- those proxy to
> > _initFrontController() -- but will only call that method if not
> > previously run. An equivalent is to call bootstrap('FrontController').
> >
> > Basically, this allows you to ensure certain resources are present prior
> > to executing a particular initializer -- such as, in your case, the
> > front controller.
> >
> >> Cristian
> >>
> >>
> >>
> >> Matthew Weier O'Phinney wrote:
> >>
> >>     -- Cristian Bichis <contact@zftutorials.com> wrote
> >>     (on Friday, 27 February 2009, 11:11 PM +0200):
> >>
> >>
> >>         Matthew Weier O'Phinney wrote:
> >>
> >>             However, I've just gone through and cleaned up all the resources to
> >>             ensure that the require_once calls are removed and that they are
> >>             appropriately declaring their dependencies, so next time you try, you
> >>             should not have these issues.
> >>
> >>
> >>
> >>             Hmmm... based on your error, I think you had an outdated checkout.
> >>
> >>         Actually require_once was from my code not Zend code.
> >>
> >>         The required classes are not developed yet as far as i know. I just checked on
> >>         SVN and no, there are not in yet. Also the #zftalk log is confirming what i
> >>         said...
> >>
> >>
> >>     Unfortunately, I'm not logged in to IRC at this time. I'm modifying the
> >>     QuickStart to use Zend_Application right now, and having no issues. Can
> >>     you, or someone else, give an example of how you're using
> >>     Zend_Application, and what errors you're running into?
> >>
> >>
> >>
> >>
> >>
> >> --
> >> Best regards,
> >> Cristian Bichis
> >> www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com
> >>
> >
> > --
> > Matthew Weier O'Phinney
> > Software Architect       | matthew@zend.com
> > Zend Framework           | http://framework.zend.com/
> >
> >
>
>
>
> --
> ----------------------------------------------------------------------
> [MuTe]
> ----------------------------------------------------------------------
>

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

Re: [fw-mvc] Proper use of Zend_Loader_Autoloader_Resource

Ah this is why it didnt work for me :)

Should the methods be private or public in the bootstrap file?

2009/2/28 Matthew Weier O'Phinney <matthew@zend.com>:
> -- Cristian Bichis <contact@zftutorials.com> wrote
> (on Saturday, 28 February 2009, 11:49 AM +0200):
>> Ok, i put up a sample based on http://framework.zend.com/wiki/display/ZFPROP/
>> Zend_Application+-+Ben+Scholzen
>>
>> I don't get the error i encountered before, but i get a new one.
>>
>> //index.php
>> <?php
>>     if( !defined('APPLICATION_ENVIRONMENT'))
>>         define('APPLICATION_ENVIRONMENT', 'production');
>>
>>     define('PUBLIC_PATH', realpath(dirname(__FILE__)));
>>     define('BASE_PATH', realpath(dirname(dirname(__FILE__))));
>>     define('APPLICATION_PATH', BASE_PATH . '/application');
>>     define('MODULE_PATH', APPLICATION_PATH . '/modules');
>>
>>     set_include_path(
>>         BASE_PATH . '/library/dasprid' . PATH_SEPARATOR
>>         .BASE_PATH . '/library/incubator' . PATH_SEPARATOR
>>         .BASE_PATH . '/library' . PATH_SEPARATOR
>>         . get_include_path()
>>     );
>>
>>     require 'Zend/Application.php';
>>
>>     $application = new Zend_Application(APPLICATION_ENVIRONMENT, array(
>>         'autoloaderNamespaces' => array(
>>             'Imagis',
>>         ),
>>         'bootstrap' => APPLICATION_PATH . '/Bootstrap.php'
>>     ));
>>
>>     $application->bootstrap();
>>
>>     Zend_Controller_Front::getInstance()->dispatch();
>> ?>
>>
>> //Bootstrap.php based on http://framework.zend.com/wiki/display/ZFPROP/
>> Zend_Application+-+Ben+Scholzen
>> <?php
>>
>> require_once 'Zend/Application/Bootstrap/Base.php';
>>
>> class Bootstrap extends Zend_Application_Bootstrap_Base
>> {
>>     public $front;
>>
>>     public function init()
>>     {
>>         $this->front = Zend_Controller_Front::getInstance();
>>     }
>>
>>     public function run()
>>     {
>>         $this->front->dispatch();
>>     }
>>
>>     protected function _initControllers()
>>     {
>>         //$this->front->setControllerDirectory(APPLICATION_PATH . '/
>> controllers', 'default');
>>         $this->front->addModuleDirectory(MODULE_PATH . '/modules');
>>         return $this;
>>     }
>>
>>     protected function _initRequest()
>>     {
>>         $this->request = new Zend_Controller_Request_Http;
>>         $this->front->setRequest($this->request);
>>         return $this;
>>     }
>> }
>>
>>
>> And the error is: Fatal error: Call to a member function addModuleDirectory()
>> on a non-object in D:\_Work\site\application\Bootstrap.php on line 22
>>
>>
>> Might be something i configured incorrectly.
>
> No -- but it does reflect that the proposal needs to be updated. :)
> There is a better example in the example.php file inside DASPRiD's user
> branch.
>
> Basically, your index.php looks good -- it's your Bootstrap class that
> isn't working correctly here, and it's due to some conventions that have
> changed as part of the proposal evaluation.
>
> First off, there is no init() method. This is offset by the fact that,
> instead, you can now do dependency checking in your initializers. As
> an example, try the following Bootstrap:
>
>    class Bootstrap extends Zend_Application_Bootstrap_Base
>    {
>        public function _initFrontController()
>        {
>            $this->front = Zend_Controller_Front::getInstance();
>        }
>
>
>        protected function _initControllers()
>        {
>            // runs _initFrontController() if not already run:
>            $this->bootstrapFrontController();
>
>            $this->front->addModuleDirectory(MODULE_PATH . '/modules');
>        }
>
>        protected function _initRequest()
>        {
>            // runs _initFrontController() if not already run:
>            $this->bootstrapFrontController();
>
>            $this->request = new Zend_Controller_Request_Http;
>            $this->front->setRequest($this->request);
>        }
>
>        public function run()
>        {
>            $this->front->dispatch();
>        }
>     }
>
> Note the calls to "bootstrapFrontController()" -- those proxy to
> _initFrontController() -- but will only call that method if not
> previously run. An equivalent is to call bootstrap('FrontController').
>
> Basically, this allows you to ensure certain resources are present prior
> to executing a particular initializer -- such as, in your case, the
> front controller.
>
>> Cristian
>>
>>
>>
>> Matthew Weier O'Phinney wrote:
>>
>>     -- Cristian Bichis <contact@zftutorials.com> wrote
>>     (on Friday, 27 February 2009, 11:11 PM +0200):
>>
>>
>>         Matthew Weier O'Phinney wrote:
>>
>>             However, I've just gone through and cleaned up all the resources to
>>             ensure that the require_once calls are removed and that they are
>>             appropriately declaring their dependencies, so next time you try, you
>>             should not have these issues.
>>
>>
>>
>>             Hmmm... based on your error, I think you had an outdated checkout.
>>
>>         Actually require_once was from my code not Zend code.
>>
>>         The required classes are not developed yet as far as i know. I just checked on
>>         SVN and no, there are not in yet. Also the #zftalk log is confirming what i
>>         said...
>>
>>
>>     Unfortunately, I'm not logged in to IRC at this time. I'm modifying the
>>     QuickStart to use Zend_Application right now, and having no issues. Can
>>     you, or someone else, give an example of how you're using
>>     Zend_Application, and what errors you're running into?
>>
>>
>>
>>
>>
>> --
>> Best regards,
>> Cristian Bichis
>> www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com
>>
>
> --
> Matthew Weier O'Phinney
> Software Architect       | matthew@zend.com
> Zend Framework           | http://framework.zend.com/
>
>

--
----------------------------------------------------------------------
[MuTe]
----------------------------------------------------------------------

Re: [fw-mvc] Proper use of Zend_Loader_Autoloader_Resource

-- Cristian Bichis <contact@zftutorials.com> wrote
(on Saturday, 28 February 2009, 12:36 PM +0200):
> May sound stupid but now i got same error. I din't changed anything back, just
> developed further.
>
> So, error is it:
>
> Warning: include(D:\_Work\site/application/modules/models//Plugins.php) [
> function.include]: failed to open stream: No such file or directory in D:\_Work
> \site\library\incubator\Zend\Loader\Autoloader\Resource.php on line 173
>
> Warning: include(D:\_Work\site/application/modules/models//Plugins.php) [
> function.include]: failed to open stream: No such file or directory in D:\_Work
> \site\library\incubator\Zend\Loader\Autoloader\Resource.php on line 173
>
> Warning: include() [function.include]: Failed opening 'D:\_Work\site/
> application/modules/models//Plugins.php' for inclusion (include_path='D:\_Work\
> site/library/dasprid;D:\_Work\site/library/incubator;D:\_Work\site/library;.;C:
> \php5\pear') in D:\_Work\site\library\incubator\Zend\Loader\Autoloader\
> Resource.php on line 173
>
> Fatal error: Class 'Default_Model_Plugins' not found in D:\_Work\site\
> application\Bootstrap.php on line 29
>
> //index.php
>
> <?php
> if( !defined('APPLICATION_ENVIRONMENT'))
> define('APPLICATION_ENVIRONMENT', 'production');
>
> define('PUBLIC_PATH', realpath(dirname(__FILE__)));
> define('BASE_PATH', realpath(dirname(dirname(__FILE__))));
> define('APPLICATION_PATH', BASE_PATH . '/application');
> define('MODULE_PATH', APPLICATION_PATH . '/modules');
>
> set_include_path(
> BASE_PATH . '/library/dasprid' . PATH_SEPARATOR
> .BASE_PATH . '/library/incubator' . PATH_SEPARATOR
> .BASE_PATH . '/library' . PATH_SEPARATOR
> . get_include_path()
> );
>
> require_once APPLICATION_PATH.'/Bootstrap.php';
>
> $boot = new Bootstrap();
> $boot->run();
> ?>
>
> //bootstrap
> // no use ofZend_Loader::registerAutoload();
>
> require 'Zend/Loader/Autoloader.php';
> require 'Zend/Loader/Autoloader/Resource.php';
>
> Zend_Loader_Autoloader::getInstance()->registerNamespace('Imagis');
>
> $loader = new Zend_Loader_Autoloader_Resource(array(
> 'namespace' => 'Default_',
> 'basePath' => MODULE_PATH
> ));

The problem is above -- the basePath should be a path _inside_ a given
module, not a path *to* the modules (which is how you've defined
MODULE_PATH). Change the above to:

'basePath' => MODULE_PATH . '/default'

and you should be fine.

> $loader->addResourceType('Model', 'models', 'Model');
> $plugins = new Default_Model_Plugins();
> ................................................
>
> I can't think to any change on bootstrap or index to led me to same error
> again... Which error was trapped by Zend_Loader::registerAutoload(), now gone.
>
> I am using now latest from SVN.
>
>
> --
> Best regards,
> Cristian Bichis
> www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com
>
>
> -- Cristian Bichis <contact@zftutorials.com> wrote
> (on Friday, 27 February 2009, 10:24 AM +0200):
>
>
> I tried last days to get in touch with some newer (or TBA) features of ZF. One
> of them is Zend_Loader_Autoloader_Resource.
>
> I made a sample for a modular archtecture. I am trying as a demonstration to
> load a Plugins model from /application/modules/default/models
>
> That's into application/Bootstrap.php:
>
> Zend_Loader::registerAutoload();
>
> $autoloader = new Zend_Loader_Autoloader_Resource(
> array(
> 'namespace' => 'Default',
> 'basePath' => MODULE_PATH
> )
> );
>
> $autoloader->addResourceTypes(array(
> 'Model' => array('path' => 'models', 'namespace' => 'Model'),
> 'DbTable' => array('path' => 'models/DbTable', 'namespace' =>
> 'DbTable')
> ));
>
>
> Okay, two things here. First, if you're going to use the Resource
> autoloader, don't uses Zend_Loader::registerAutoload(); use
> Zend_Loader_Autoloader -- and the latter is implicit when you
> instantiate the resource autoloader.
>
> Second, based on the resource types you're defining, you probably want
> to use the Zend_Application_Module_Autoloader variant, as it has all of
> the resources you indicated above defined already.
>
> In the end, it would look like this:
>
> $autoloader = new Zend_Application_Module_Autoloader(array(
> 'namespace' => 'Default_',
> 'basePath' => MODULE_PATH,
> ));
>
> and that's it.
>
>

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

[fw-mvc] Where to initialize Zend_Translate

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkmpRJ0ACgkQsxtAFVfnNCQh+QCglDss65Znr+ICOM2zLyrwN1hM
6RcAnRj9DNQj8w6IPVL5wEAiC7m0WhFA
=+UwX
-----END PGP SIGNATURE-----
Hi,

I want to ask you, where should I initialize Zend_Translate, on manual
pages isn't any recommendation

I have craete one Init plugin like this:
[code]
<?php
class InitPlugin extends Zend_Controller_Plugin_Abstract
{
public function routeStartup(Zend_Controller_Request_Abstract $request)
{
while (true) {
;
};
}

public function routeShutdown(Zend_Controller_Request_Abstract $request)
{}

public function dispatchLoopStartup(Zend_Controller_Request_Abstract
$request)
{
Zend_Controller_Action_HelperBroker::addHelper(new
Flox_Controller_Action_Helper_Init());
}

public function preDispatch(Zend_Controller_Request_Abstract $request)
{
}

public function postDispatch(Zend_Controller_Request_Abstract $request)
{
}

public function dispatchLoopShutdown()
{}
}
[/code]

Is the event dispatchLoopStartup the right place where should I init
Zend_Translate ?


Thank you for any suggestions and advices

--
-------------------------------------------------------------------
--== Silver Zachara ==--
- pgp - http://radeonvmod.ic.cz/keys/silver.zachara@gmail.com.asc -

Re: [fw-mvc] Proper use of Zend_Loader_Autoloader_Resource

-- Cristian Bichis <contact@zftutorials.com> wrote
(on Saturday, 28 February 2009, 11:49 AM +0200):
> Ok, i put up a sample based on http://framework.zend.com/wiki/display/ZFPROP/
> Zend_Application+-+Ben+Scholzen
>
> I don't get the error i encountered before, but i get a new one.
>
> //index.php
> <?php
> if( !defined('APPLICATION_ENVIRONMENT'))
> define('APPLICATION_ENVIRONMENT', 'production');
>
> define('PUBLIC_PATH', realpath(dirname(__FILE__)));
> define('BASE_PATH', realpath(dirname(dirname(__FILE__))));
> define('APPLICATION_PATH', BASE_PATH . '/application');
> define('MODULE_PATH', APPLICATION_PATH . '/modules');
>
> set_include_path(
> BASE_PATH . '/library/dasprid' . PATH_SEPARATOR
> .BASE_PATH . '/library/incubator' . PATH_SEPARATOR
> .BASE_PATH . '/library' . PATH_SEPARATOR
> . get_include_path()
> );
>
> require 'Zend/Application.php';
>
> $application = new Zend_Application(APPLICATION_ENVIRONMENT, array(
> 'autoloaderNamespaces' => array(
> 'Imagis',
> ),
> 'bootstrap' => APPLICATION_PATH . '/Bootstrap.php'
> ));
>
> $application->bootstrap();
>
> Zend_Controller_Front::getInstance()->dispatch();
> ?>
>
> //Bootstrap.php based on http://framework.zend.com/wiki/display/ZFPROP/
> Zend_Application+-+Ben+Scholzen
> <?php
>
> require_once 'Zend/Application/Bootstrap/Base.php';
>
> class Bootstrap extends Zend_Application_Bootstrap_Base
> {
> public $front;
>
> public function init()
> {
> $this->front = Zend_Controller_Front::getInstance();
> }
>
> public function run()
> {
> $this->front->dispatch();
> }
>
> protected function _initControllers()
> {
> //$this->front->setControllerDirectory(APPLICATION_PATH . '/
> controllers', 'default');
> $this->front->addModuleDirectory(MODULE_PATH . '/modules');
> return $this;
> }
>
> protected function _initRequest()
> {
> $this->request = new Zend_Controller_Request_Http;
> $this->front->setRequest($this->request);
> return $this;
> }
> }
>
>
> And the error is: Fatal error: Call to a member function addModuleDirectory()
> on a non-object in D:\_Work\site\application\Bootstrap.php on line 22
>
>
> Might be something i configured incorrectly.

No -- but it does reflect that the proposal needs to be updated. :)
There is a better example in the example.php file inside DASPRiD's user
branch.

Basically, your index.php looks good -- it's your Bootstrap class that
isn't working correctly here, and it's due to some conventions that have
changed as part of the proposal evaluation.

First off, there is no init() method. This is offset by the fact that,
instead, you can now do dependency checking in your initializers. As
an example, try the following Bootstrap:

class Bootstrap extends Zend_Application_Bootstrap_Base
{
public function _initFrontController()
{
$this->front = Zend_Controller_Front::getInstance();
}


protected function _initControllers()
{
// runs _initFrontController() if not already run:
$this->bootstrapFrontController();

$this->front->addModuleDirectory(MODULE_PATH . '/modules');
}

protected function _initRequest()
{
// runs _initFrontController() if not already run:
$this->bootstrapFrontController();

$this->request = new Zend_Controller_Request_Http;
$this->front->setRequest($this->request);
}

public function run()
{
$this->front->dispatch();
}
}

Note the calls to "bootstrapFrontController()" -- those proxy to
_initFrontController() -- but will only call that method if not
previously run. An equivalent is to call bootstrap('FrontController').

Basically, this allows you to ensure certain resources are present prior
to executing a particular initializer -- such as, in your case, the
front controller.

> Cristian
>
>
>
> Matthew Weier O'Phinney wrote:
>
> -- Cristian Bichis <contact@zftutorials.com> wrote
> (on Friday, 27 February 2009, 11:11 PM +0200):
>
>
> Matthew Weier O'Phinney wrote:
>
> However, I've just gone through and cleaned up all the resources to
> ensure that the require_once calls are removed and that they are
> appropriately declaring their dependencies, so next time you try, you
> should not have these issues.
>
>
>
> Hmmm... based on your error, I think you had an outdated checkout.
>
> Actually require_once was from my code not Zend code.
>
> The required classes are not developed yet as far as i know. I just checked on
> SVN and no, there are not in yet. Also the #zftalk log is confirming what i
> said...
>
>
> Unfortunately, I'm not logged in to IRC at this time. I'm modifying the
> QuickStart to use Zend_Application right now, and having no issues. Can
> you, or someone else, give an example of how you're using
> Zend_Application, and what errors you're running into?
>
>
>
>
>
> --
> Best regards,
> Cristian Bichis
> www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com
>

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

Re: [fw-db] Column ambiguously defined

Just an idea, but what about writing the query your own?
I don't know about Oracle, but I did somewhere in my code with mysql:

$db = Zend_Registry::get('db'); // getting my db connection
$results = $db->query('SELECT * FROM bla bla INNER JOIN bla bla WHERE
...')->fetchAll();

-----
visit my website at http://www.phpscriptor.com/ http://www.phpscriptor.com/
--
View this message in context: http://www.nabble.com/Column-ambiguously-defined-tp22248675p22260915.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-mvc] Proper use of Zend_Loader_Autoloader_Resource

Hi,

May sound stupid but now i got same error. I din't changed anything back, just developed further.

So, error is it:

Warning: include(D:\_Work\site/application/modules/models//Plugins.php) [function.include]: failed to open stream: No such file or directory in D:\_Work\site\library\incubator\Zend\Loader\Autoloader\Resource.php on line 173

Warning: include(D:\_Work\site/application/modules/models//Plugins.php) [function.include]: failed to open stream: No such file or directory in D:\_Work\site\library\incubator\Zend\Loader\Autoloader\Resource.php on line 173

Warning: include() [function.include]: Failed opening 'D:\_Work\site/application/modules/models//Plugins.php' for inclusion (include_path='D:\_Work\site/library/dasprid;D:\_Work\site/library/incubator;D:\_Work\site/library;.;C:\php5\pear') in D:\_Work\site\library\incubator\Zend\Loader\Autoloader\Resource.php on line 173

Fatal error: Class 'Default_Model_Plugins' not found in D:\_Work\site\application\Bootstrap.php on line 29

//index.php

<?php
    if( !defined('APPLICATION_ENVIRONMENT'))
        define('APPLICATION_ENVIRONMENT', 'production');
       
    define('PUBLIC_PATH', realpath(dirname(__FILE__)));
    define('BASE_PATH', realpath(dirname(dirname(__FILE__))));
    define('APPLICATION_PATH', BASE_PATH . '/application');
    define('MODULE_PATH', APPLICATION_PATH . '/modules');
   
    set_include_path(
        BASE_PATH . '/library/dasprid' . PATH_SEPARATOR
        .BASE_PATH . '/library/incubator' . PATH_SEPARATOR
        .BASE_PATH . '/library' . PATH_SEPARATOR
        . get_include_path()
    );
   
    require_once APPLICATION_PATH.'/Bootstrap.php';
   
    $boot = new Bootstrap();
    $boot->run();
?>

//bootstrap
// no use ofZend_Loader::registerAutoload();

         require 'Zend/Loader/Autoloader.php';
        require 'Zend/Loader/Autoloader/Resource.php';
       
        Zend_Loader_Autoloader::getInstance()->registerNamespace('Imagis');
       
        $loader = new Zend_Loader_Autoloader_Resource(array(
             'namespace' => 'Default_',
             'basePath'  => MODULE_PATH
        ));
       
        $loader->addResourceType('Model', 'models', 'Model');
        $plugins = new Default_Model_Plugins();
       ................................................

I can't think to any change on bootstrap or index to led me to same error again... Which error was trapped by Zend_Loader::registerAutoload(), now gone.

I am using now latest from SVN.

--  Best regards, Cristian Bichis www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com

-- Cristian Bichis <contact@zftutorials.com> wrote (on Friday, 27 February 2009, 10:24 AM +0200):   
I tried last days to get in touch with some newer (or TBA) features of ZF. One of them is Zend_Loader_Autoloader_Resource.  I made a sample for a modular archtecture. I am trying as a demonstration to load a Plugins model from /application/modules/default/models  That's into application/Bootstrap.php:          Zend_Loader::registerAutoload();                 $autoloader = new Zend_Loader_Autoloader_Resource(             array(             'namespace'   => 'Default',             'basePath' => MODULE_PATH             )         );                 $autoloader->addResourceTypes(array(                 'Model' => array('path' => 'models', 'namespace' => 'Model'),                 'DbTable'  => array('path' => 'models/DbTable', 'namespace' => 'DbTable')         ));     
 Okay, two things here. First, if you're going to use the Resource autoloader, don't uses Zend_Loader::registerAutoload(); use Zend_Loader_Autoloader -- and the latter is implicit when you instantiate the resource autoloader.  Second, based on the resource types you're defining, you probably want to use the Zend_Application_Module_Autoloader variant, as it has all of the resources you indicated above defined already.  In the end, it would look like this:      $autoloader = new Zend_Application_Module_Autoloader(array(         'namespace' => 'Default_',         'basePath'  => MODULE_PATH,     ));  and that's it.

Re: [fw-mvc] Proper use of Zend_Loader_Autoloader_Resource

Hi,

Ok, i put up a sample based on http://framework.zend.com/wiki/display/ZFPROP/Zend_Application+-+Ben+Scholzen

I don't get the error i encountered before, but i get a new one.

//index.php
<?php
    if( !defined('APPLICATION_ENVIRONMENT'))
        define('APPLICATION_ENVIRONMENT', 'production');
       
    define('PUBLIC_PATH', realpath(dirname(__FILE__)));
    define('BASE_PATH', realpath(dirname(dirname(__FILE__))));
    define('APPLICATION_PATH', BASE_PATH . '/application');
    define('MODULE_PATH', APPLICATION_PATH . '/modules');
   
    set_include_path(
        BASE_PATH . '/library/dasprid' . PATH_SEPARATOR
        .BASE_PATH . '/library/incubator' . PATH_SEPARATOR
        .BASE_PATH . '/library' . PATH_SEPARATOR
        . get_include_path()
    );
   
    require 'Zend/Application.php';
   
    $application = new Zend_Application(APPLICATION_ENVIRONMENT, array(
        'autoloaderNamespaces' => array(
            'Imagis',
        ),
        'bootstrap' => APPLICATION_PATH . '/Bootstrap.php'
    ));
   
    $application->bootstrap();
     
    Zend_Controller_Front::getInstance()->dispatch();
?>

//Bootstrap.php based on http://framework.zend.com/wiki/display/ZFPROP/Zend_Application+-+Ben+Scholzen
<?php

require_once 'Zend/Application/Bootstrap/Base.php';

class Bootstrap extends Zend_Application_Bootstrap_Base
{
    public $front;
 
    public function init()
    {
        $this->front = Zend_Controller_Front::getInstance();
    }
 
    public function run()
    {
        $this->front->dispatch();
    }
 
    protected function _initControllers()
    {
        //$this->front->setControllerDirectory(APPLICATION_PATH . '/controllers', 'default');
        $this->front->addModuleDirectory(MODULE_PATH . '/modules');
        return $this;
    }
 
    protected function _initRequest()
    {
        $this->request = new Zend_Controller_Request_Http;
        $this->front->setRequest($this->request);
        return $this;
    }
}


And the error is: Fatal error: Call to a member function addModuleDirectory() on a non-object in D:\_Work\site\application\Bootstrap.php on line 22


Might be something i configured incorrectly.

Cristian



Matthew Weier O'Phinney wrote:
-- Cristian Bichis <contact@zftutorials.com> wrote (on Friday, 27 February 2009, 11:11 PM +0200):   
Matthew Weier O'Phinney wrote:      However, I've just gone through and cleaned up all the resources to     ensure that the require_once calls are removed and that they are     appropriately declaring their dependencies, so next time you try, you     should not have these issues.        Hmmm... based on your error, I think you had an outdated checkout.  Actually require_once was from my code not Zend code.  The required classes are not developed yet as far as i know. I just checked on SVN and no, there are not in yet. Also the #zftalk log is confirming what i said...     
 Unfortunately, I'm not logged in to IRC at this time. I'm modifying the QuickStart to use Zend_Application right now, and having no issues. Can you, or someone else, give an example of how you're using Zend_Application, and what errors you're running into?    


--  Best regards, Cristian Bichis www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com

Re: [fw-db] Column ambiguously defined


Trust me I tried everything with Zend  and nothing works.
Actually, it's a bug with Oracle database : http://framework.zend.com/issues/browse/ZF-3168

I have to deliver my web application for Monday... Bad weekend expected!

--
Thomas VEQUAUD          http://thomas.vequaud.free.fr/
Expert EPITECH en Ingénierie Informatique
Tél : +33(0)6.50.39.28.10  Fax: +33(0)9.58.46.10.07


On Fri, Feb 27, 2009 at 11:40 PM, PHPScriptor <contact@phpscriptor.com> wrote:

Oh yeah, I see it, didn't look good enough... anyway. You should rename one
of the id's.

e.g. the one from INDIVIDUS: IND_ID AS BLABLA. But better I think, you
should only let the select, select one of the two id's.

e.g.
$select->joinInner(array("AFF" => "EAI_TA_AFFECTATIONS"),
    'INDIVIDUS.IND_ID = AFF.IND_ID',array('field1','field2','field3));
so the 3the parameter is the fields you want to select from this table.
Select them all but not IND_ID.

http://www.phpscriptor.com/tutorial/zend/zend.db.select.html#zend.db.select.building.join
http://www.phpscriptor.com/tutorial/zend/zend.db.select.html#zend.db.select.building.join


Thomas VEQUAUD wrote:
>
> Yep I have an IND_ID in each tables... That's why I don't understand this
> issue...
> If you've got another idea... Just show me the right way! ;)
>

2009年2月27日星期五

Re: [fw-db] Column ambiguously defined

Oh yeah, I see it, didn't look good enough... anyway. You should rename one
of the id's.

e.g. the one from INDIVIDUS: IND_ID AS BLABLA. But better I think, you
should only let the select, select one of the two id's.

e.g.
$select->joinInner(array("AFF" => "EAI_TA_AFFECTATIONS"),
'INDIVIDUS.IND_ID = AFF.IND_ID',array('field1','field2','field3));
so the 3the parameter is the fields you want to select from this table.
Select them all but not IND_ID.

http://www.phpscriptor.com/tutorial/zend/zend.db.select.html#zend.db.select.building.join
http://www.phpscriptor.com/tutorial/zend/zend.db.select.html#zend.db.select.building.join


Thomas VEQUAUD wrote:
>
> Yep I have an IND_ID in each tables... That's why I don't understand this
> issue...
> If you've got another idea... Just show me the right way! ;)
>


-----
visit my website at http://www.phpscriptor.com/ http://www.phpscriptor.com/
--
View this message in context: http://www.nabble.com/Column-ambiguously-defined-tp22248675p22255854.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-gdata] Zend_Gdata_Calendar_EventEntry posting to shared calendars

Thanks for the note back Trevor,

I had/have actually been through that documentation .. :). As it stands
I have a user [userA] that has access to a shared calendar owned by
userB -- I haven't found/seen any documentation about how userA can
programatically (using something like "
$gdataCal = new Zend_Gdata_Calendar($client);
$newEvent = $gdataCal->newEventEntry();
" ) that will let me update userB's calendar. I'm sure I'm
missing something fairly straight forward. I have managed to set up a
query to retrieve events with this snippet of code "

$query = $gdataCal->newEventQuery();
$query->setUser($calendarFeed);

" to retrieve a shared calendar list.

Thanks again for your note back,

best regards,
Tim


Trevor Johns wrote:
> On Fri, Feb 27, 2009 at 6:19 AM, Red Rabbit <tim@redrabbit.ca> wrote:
>
>> I've had a good google, and I apologize if this is either the wrong forum, or
>> if the question has been asked and answered, but I haven't had any luck
>> finding it.
>>
>> I have an application that is talking to google calendars using the php api,
>> i've been able to successfully pull information from calendars shared with
>> my user, but I've not found any information on how to write to a specific
>> calendar -- there are some gentle references to being able to do it, so I
>> know it's probably something stupid that I've missed.
>>
>> Any suggestions would be greatly appreciated - either where to go looking or
>> even more helpful would be a snippet of code.
>>
>> TIA,
>>
>> Tim.
>>
>
> Hi Tim,
> We have a developer's guide on code.google.com that you might find
> useful. Specifically, you'll want to see the section on creating
> events, here:
>
> http://code.google.com/apis/calendar/docs/1.0/developers_guide_php.html#CreatingEvents
>
> Let me know if that helps, or if you need more information.
>
>

Re: [fw-mvc] Proper use of Zend_Loader_Autoloader_Resource

-- Cristian Bichis <contact@zftutorials.com> wrote
(on Friday, 27 February 2009, 11:11 PM +0200):
> Matthew Weier O'Phinney wrote:
>
> However, I've just gone through and cleaned up all the resources to
> ensure that the require_once calls are removed and that they are
> appropriately declaring their dependencies, so next time you try, you
> should not have these issues.
>
>
>
> Hmmm... based on your error, I think you had an outdated checkout.
>
> Actually require_once was from my code not Zend code.
>
> The required classes are not developed yet as far as i know. I just checked on
> SVN and no, there are not in yet. Also the #zftalk log is confirming what i
> said...

Unfortunately, I'm not logged in to IRC at this time. I'm modifying the
QuickStart to use Zend_Application right now, and having no issues. Can
you, or someone else, give an example of how you're using
Zend_Application, and what errors you're running into?

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

Re: [fw-mvc] Proper use of Zend_Loader_Autoloader_Resource

Matthew Weier O'Phinney wrote:

 I should have been more explicit about what $autoloader is - it's an instance of Zend_Loader_Autoloader, not the resource autoloader:      Zend_Loader_Autoloader::getInstance()->registerNamespace('Imagis');  same things goes for doing fallback:      Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);  (Zend_Loader_Autoloader::getInstance() replaces $autoloader in my original email)   
Works now. So no bug here :)

--  Best regards, Cristian Bichis www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com

Re: [fw-mvc] Proper use of Zend_Loader_Autoloader_Resource

Matthew Weier O'Phinney wrote:
However, I've just gone through and cleaned up all the resources to ensure that the require_once calls are removed and that they are appropriately declaring their dependencies, so next time you try, you should not have these issues.    
Hmmm... based on your error, I think you had an outdated checkout.
Actually require_once was from my code not Zend code.

The required classes are not developed yet as far as i know. I just checked on SVN and no, there are not in yet. Also the #zftalk log is confirming what i said...
--  Best regards, Cristian Bichis www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com

Re: [fw-mvc] Proper use of Zend_Loader_Autoloader_Resource

-- Cristian Bichis <contact@zftutorials.com> wrote
(on Friday, 27 February 2009, 10:40 PM +0200):
> Matthew Weier O'Phinney wrote:
>
> -- Cristian Bichis <contact@zftutorials.com> wrote
> (on Friday, 27 February 2009, 10:13 PM +0200):
>
>
> Zend_Loader_Autoloader is a namespace based autoloader -- this allows it
> to bail early if a namespace is not found -- this is particularly useful
> if you have other autoloaders in play.
>
> You can enable additional namespaces easily:
>
> $autoloader->registerNamespace('Imagis');
>
>
>
> Fatal error: Uncaught exception 'Zend_Loader_Exception' with message 'Method
> 'registerNamespace' is not supported' in D:\_Work\site\library\incubator\Zend\
> Loader\Autoloader\Resource.php:128

I should have been more explicit about what $autoloader is - it's an
instance of Zend_Loader_Autoloader, not the resource autoloader:

Zend_Loader_Autoloader::getInstance()->registerNamespace('Imagis');

same things goes for doing fallback:

Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);

(Zend_Loader_Autoloader::getInstance() replaces $autoloader in my
original email)

> Stack trace: #0 [internal function]:
> Zend_Loader_Autoloader_Resource->__call('registerNamespa...', Array) #1 D:\
> _Work\site\application\Bootstrap.php(30): Zend_Loader_Autoloader_Resource->
> registerNamespace('Imagis') #2 D:\_Work\site\public\index.php(20):
> Bootstrap::run() #3 {main} thrown in D:\_Work\site\library\incubator\Zend\
> Loader\Autoloader\Resource.php on line 128
>
> You can also tell the autoloader to be a "fallback" autoloader -- i.e.,
> if the namespace isn't registered, it will still attempt to load it:
>
> $autoloader->setFallbackAutoloader(true);
>
>
>
> Fatal error: Uncaught exception 'Zend_Loader_Exception' with message 'Method
> 'setFallbackAutoloader' is not supported' in D:\_Work\site\library\incubator\
> Zend\Loader\Autoloader\Resource.php:128 Stack trace: #0 [internal function]:
> Zend_Loader_Autoloader_Resource->__call('setFallbackAuto...', Array) #1 D:\
> _Work\site\application\Bootstrap.php(29): Zend_Loader_Autoloader_Resource->
> setFallbackAutoloader(true) #2 D:\_Work\site\public\index.php(20):
> Bootstrap::run() #3 {main} thrown in D:\_Work\site\library\incubator\Zend\
> Loader\Autoloader\Resource.php on line 128
>
> I have an up to date version of autoloader from SVN.
>
>
> --
> Best regards,
> Cristian Bichis
> www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com
>

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

Re: [fw-mvc] Proper use of Zend_Loader_Autoloader_Resource

-- Cristian Bichis <contact@zftutorials.com> wrote
(on Friday, 27 February 2009, 10:37 PM +0200):
> Thanks.
>
> Any idea which would be the faster (as performance) approach ?
>
>
> $autoloader->registerNamespace('Imagis');
>
> or
>
> $autoloader->setFallbackAutoloader(true);

The first one. Fallback autoloading implies you don't know the
namespaces that will be used in your application, and doesn't do
optimistic lookups.


> -- Cristian Bichis <contact@zftutorials.com> wrote
> (on Friday, 27 February 2009, 10:13 PM +0200):
>
>
> Hmmm,
>
> I noticed one potential problem with autoloader. It might my fault anyway...
>
> Seems i can't load some non Zend classes from library now after i switched to
> Resource autoloader.
>
>
> Zend_Loader_Autoloader is a namespace based autoloader -- this allows it
> to bail early if a namespace is not found -- this is particularly useful
> if you have other autoloaders in play.
>
> You can enable additional namespaces easily:
>
> $autoloader->registerNamespace('Imagis');
>
> You can also tell the autoloader to be a "fallback" autoloader -- i.e.,
> if the namespace isn't registered, it will still attempt to load it:
>
> $autoloader->setFallbackAutoloader(true);
>
>
>
>
> index.php:
> set_include_path(
> BASE_PATH . '/library/dasprid' . PATH_SEPARATOR
> .BASE_PATH . '/library/incubator' . PATH_SEPARATOR
> .BASE_PATH . '/library' . PATH_SEPARATOR
> . get_include_path()
> );
>
> Bootstrap:
>
> require 'Zend/Loader/Autoloader.php';
> require 'Zend/Loader/Autoloader/Resource.php';
>
> $loader = new Zend_Loader_Autoloader_Resource(array(
> 'namespace' => 'Default_',
> 'basePath' => MODULE_PATH
> ));
>
> $loader->addResourceType('Model', 'models', 'Model');
> //i used resource autoloader since i would add also forms, filters, aso
> .................................................
> $acl = new Imagis_Acl($auth);
> //class Imagis_ACL is obviously into library/Imagis (class Imagis_Acl
> extends Zend_Acl)
>
>
> But... I am receiving this:
>
>
> Fatal error: Class 'Imagis_Acl' not found in D:\_Work\site\application\
> Bootstrap.php on line 174
>
> Not sure, might be my fault...
>
>
>
> --
> Best regards,
> Cristian Bichis
> www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com
>
>
>
> -- Cristian Bichis <contact@zftutorials.com> wrote
> (on Friday, 27 February 2009, 07:01 PM +0200):
>
>
> Thanks for reply, my code works now... :)
>
> One more question. How should i make the system automatically
> recognize all my modules ?
>
>
>
>
> I know this is also related to Zend_Application prepared by Dasprid, i
> am wondering if this is possible (using just autoloader) until his
> component is released (is not moved to incubator now).
>
>
> Loop through your modules, and instantiate an autoloader for each:
>
> $loaders = array();
> foreach ($front->getControllerDirectory() as $module => $dir) {
> $loaders[$module] = new Zend_Application_Module_Autoloader(array(
> 'namespace' => ucfirst($module),
> 'basePath' => dirname($dir),
> ));
> }
>
> You can also grab Zend_Application from svn:
>
> http://framework.zend.com/svn/framework/standard/branches/dasprid/Zend_Application
>
> BTW, Zend_Application is being hacked on by more than just DASPRiD -- if
> you have ideas or feedback, please feel free to comment.
>
>
>
> Matthew Weier O'Phinney wrote:
>
> -- Cristian Bichis <contact@zftutorials.com> wrote
> (on Friday, 27 February 2009, 10:24 AM +0200):
>
>
> I tried last days to get in touch with some newer (or TBA) features of ZF. One
> of them is Zend_Loader_Autoloader_Resource.
>
> I made a sample for a modular archtecture. I am trying as a demonstration to
> load a Plugins model from /application/modules/default/models
>
> That's into application/Bootstrap.php:
>
> Zend_Loader::registerAutoload();
>
> $autoloader = new Zend_Loader_Autoloader_Resource(
> array(
> 'namespace' => 'Default',
> 'basePath' => MODULE_PATH
> )
> );
>
> $autoloader->addResourceTypes(array(
> 'Model' => array('path' => 'models', 'namespace' => 'Model'),
> 'DbTable' => array('path' => 'models/DbTable', 'namespace' =>
> 'DbTable')
> ));
>
>
> Okay, two things here. First, if you're going to use the Resource
> autoloader, don't uses Zend_Loader::registerAutoload(); use
> Zend_Loader_Autoloader -- and the latter is implicit when you
> instantiate the resource autoloader.
>
> Second, based on the resource types you're defining, you probably want
> to use the Zend_Application_Module_Autoloader variant, as it has all of
> the resources you indicated above defined already.
>
> In the end, it would look like this:
>
> $autoloader = new Zend_Application_Module_Autoloader(array(
> 'namespace' => 'Default_',
> 'basePath' => MODULE_PATH,
> ));
>
> and that's it.
>
>
>
> Into a controller plugin in am making use of resource autoloader this way:
>
> $plugins = new Default_Model_Plugins();
>
>
> Now here are my questions:
> 1. Why i am receiving this error:
>
> Warning: include(D:\_Work\site/application/modules/models//Plugins.php) [
> function.include]: failed to open stream: No such file or directory in D:\_Work
> \site\library\incubator\Zend\Loader\Autoloader\Resource.php on line 173
>
> I am not sure why is not included the "default" into path... Or anyway, what i
> am missing ?
>
>
> First, getting rid of the Zend_Loader::registerAutoload() will likely
> take care of this. Second, use Zend_Loader from current trunk, as it has
> a few changes that make it work better with autoloading.
>
>
>
> 2. There is any other error ? Like namespace been 'namespace' => 'Default'
> or 'namespace' => 'Default_', as according to sample from incubator file
> ('namespace' => 'Stuff_').
>
>
> I need to change that in the docblock -- no '_' suffix necessary with
> resource autoloaders. The reason is that with resource autoloading,
> we're making an assumption that the classes follow ZF coding standards
> -- so the '_' is implied. (Zend_Loader_Autoloader, however, does require
> the explicit '_' so that we can allow interop with autoloaders from
> projects that do not follow the same conventions).
>
>
>
> 3. How should be the class name of the model ? Plugins ? Or Default_Plugins ?
> or Default_Model_Plugins ?
>
>
> Default_Model_Plugins. Rule of thumb: the namespace you use is the first
> segment, the resource type is the second segment, and then the class
> name is the last.
>
> /me makes a note to write documentation soon!
>
>
>
>
>
> --
> Best regards,
> Cristian Bichis
> www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com
>
>
>
>
>
>
>
>
>
>
>
>
> --
> Best regards,
> Cristian Bichis
> www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com
>

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

Re: [fw-mvc] Proper use of Zend_Loader_Autoloader_Resource

-- Cristian Bichis <contact@zftutorials.com> wrote
(on Friday, 27 February 2009, 10:34 PM +0200):
> Matthew Weier O'Phinney wrote:
>
> version from svn isn't quite ready so testing options are limited.
>
>
> Can you elaborate?
>
> I ask because I've actually used it in some sample sites to ensure it
> was working as expected (in lieu of tests, which I'm waiting on until
> we're sure the API is basically final). Is there something specific not
> working for you? I'd like to know, so that we can see if it's a use case
> we want to support.
>
>
>
> I deleted that test project so can't test again right now. I need some time to
> re-create the code.
>
> Anyway, i got confirm that some of the classes are not yet implemented so
> that's why my demo failed. See below also the error, and a short log from #
> zftalk.

Hmmm... based on your error, I think you had an outdated checkout.
However, I've just gone through and cleaned up all the resources to
ensure that the require_once calls are removed and that they are
appropriately declaring their dependencies, so next time you try, you
should not have these issues.

>
> (10:44:27) cbichis:
> hi
> (10:44:32) DASPRiD:
> hi
> (10:44:39) cbichis:
> i got some probs with Zend_App
> (10:44:51) cbichis:
> Warning: require_once(Zend/Application/Bootstrap/Resource/Base.php)
> [function.require-once]: failed to open stream: No such file or directory in D:
> \_Work\site\library\dasprid\Zend\Application\Resource\Frontcontroller.php on
> line 26
> (10:45:05) DASPRiD:
> you got probs with an alpha version? :>
> (10:45:33) cbichis:
> ok, just wanted to send you the nug ;)
> (10:45:39) cbichis:
> bug *
> (10:45:47) DASPRiD:
> ty
>
> Since i am interested about subject i can make other tests if needed
>
>
> --
> Best regards,
> Cristian Bichis
> www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com
>

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

Re: [fw-mvc] Proper use of Zend_Loader_Autoloader_Resource

Matthew Weier O'Phinney wrote:
-- Cristian Bichis <contact@zftutorials.com> wrote (on Friday, 27 February 2009, 10:13 PM +0200):   
 Zend_Loader_Autoloader is a namespace based autoloader -- this allows it to bail early if a namespace is not found -- this is particularly useful if you have other autoloaders in play.  You can enable additional namespaces easily:      $autoloader->registerNamespace('Imagis');   

Fatal error: Uncaught exception 'Zend_Loader_Exception' with message 'Method 'registerNamespace' is not supported' in D:\_Work\site\library\incubator\Zend\Loader\Autoloader\Resource.php:128 Stack trace: #0 [internal function]: Zend_Loader_Autoloader_Resource->__call('registerNamespa...', Array) #1 D:\_Work\site\application\Bootstrap.php(30): Zend_Loader_Autoloader_Resource->registerNamespace('Imagis') #2 D:\_Work\site\public\index.php(20): Bootstrap::run() #3 {main} thrown in D:\_Work\site\library\incubator\Zend\Loader\Autoloader\Resource.php on line 128
 You can also tell the autoloader to be a "fallback" autoloader -- i.e., if the namespace isn't registered, it will still attempt to load it:      $autoloader->setFallbackAutoloader(true);   

Fatal error: Uncaught exception 'Zend_Loader_Exception' with message 'Method 'setFallbackAutoloader' is not supported' in D:\_Work\site\library\incubator\Zend\Loader\Autoloader\Resource.php:128 Stack trace: #0 [internal function]: Zend_Loader_Autoloader_Resource->__call('setFallbackAuto...', Array) #1 D:\_Work\site\application\Bootstrap.php(29): Zend_Loader_Autoloader_Resource->setFallbackAutoloader(true) #2 D:\_Work\site\public\index.php(20): Bootstrap::run() #3 {main} thrown in D:\_Work\site\library\incubator\Zend\Loader\Autoloader\Resource.php on line 128

I have an up to date version of autoloader from SVN.

--  Best regards, Cristian Bichis www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com

Re: [fw-mvc] Proper use of Zend_Loader_Autoloader_Resource

Thanks.

Any idea which would be the faster (as performance) approach ?

$autoloader->registerNamespace('Imagis');
or
$autoloader->setFallbackAutoloader(true);
?
-- Cristian Bichis <contact@zftutorials.com> wrote (on Friday, 27 February 2009, 10:13 PM +0200):   
Hmmm,  I noticed one potential problem with autoloader. It might my fault anyway...  Seems i can't load some non Zend classes from library now after i switched to Resource autoloader.     
 Zend_Loader_Autoloader is a namespace based autoloader -- this allows it to bail early if a namespace is not found -- this is particularly useful if you have other autoloaders in play.  You can enable additional namespaces easily:      $autoloader->registerNamespace('Imagis');  You can also tell the autoloader to be a "fallback" autoloader -- i.e., if the namespace isn't registered, it will still attempt to load it:      $autoloader->setFallbackAutoloader(true);     
index.php:     set_include_path(         BASE_PATH . '/library/dasprid' . PATH_SEPARATOR         .BASE_PATH . '/library/incubator' . PATH_SEPARATOR         .BASE_PATH . '/library' . PATH_SEPARATOR         . get_include_path()     );  Bootstrap:          require 'Zend/Loader/Autoloader.php';         require 'Zend/Loader/Autoloader/Resource.php';                 $loader = new Zend_Loader_Autoloader_Resource(array(              'namespace' => 'Default_',              'basePath'  => MODULE_PATH         ));                 $loader->addResourceType('Model', 'models', 'Model');        //i used resource autoloader since i would add also forms, filters, aso        .................................................         $acl = new Imagis_Acl($auth);        //class Imagis_ACL is obviously into library/Imagis   (class Imagis_Acl extends Zend_Acl)   But... I am receiving this:   Fatal error: Class 'Imagis_Acl' not found in D:\_Work\site\application\ Bootstrap.php on line 174  Not sure, might be my fault...    -- Best regards, Cristian Bichis www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com        -- Cristian Bichis <contact@zftutorials.com> wrote     (on Friday, 27 February 2009, 07:01 PM +0200):           Thanks for reply, my code works now... :)          One more question. How should i make the system automatically         recognize all my modules ?             I know this is also related to Zend_Application prepared by Dasprid, i         am wondering if this is possible (using just autoloader) until his         component is released (is not moved to incubator now).       Loop through your modules, and instantiate an autoloader for each:          $loaders = array();         foreach ($front->getControllerDirectory() as $module => $dir) {             $loaders[$module] = new Zend_Application_Module_Autoloader(array(                 'namespace' => ucfirst($module),                 'basePath'  => dirname($dir),             ));         }      You can also grab Zend_Application from svn:          http://framework.zend.com/svn/framework/standard/branches/dasprid/Zend_Application      BTW, Zend_Application is being hacked on by more than just DASPRiD -- if     you have ideas or feedback, please feel free to comment.            Matthew Weier O'Phinney wrote:              -- Cristian Bichis <contact@zftutorials.com> wrote             (on Friday, 27 February 2009, 10:24 AM +0200):                   I tried last days to get in touch with some newer (or TBA) features of ZF. One                 of them is Zend_Loader_Autoloader_Resource.                  I made a sample for a modular archtecture. I am trying as a demonstration to                 load a Plugins model from /application/modules/default/models                  That's into application/Bootstrap.php:                          Zend_Loader::registerAutoload();                          $autoloader = new Zend_Loader_Autoloader_Resource(                             array(                             'namespace'   => 'Default',                             'basePath' => MODULE_PATH                             )                         );                          $autoloader->addResourceTypes(array(                                 'Model' => array('path' => 'models', 'namespace' => 'Model'),                                 'DbTable'  => array('path' => 'models/DbTable', 'namespace' =>                 'DbTable')                         ));               Okay, two things here. First, if you're going to use the Resource             autoloader, don't uses Zend_Loader::registerAutoload(); use             Zend_Loader_Autoloader -- and the latter is implicit when you             instantiate the resource autoloader.              Second, based on the resource types you're defining, you probably want             to use the Zend_Application_Module_Autoloader variant, as it has all of             the resources you indicated above defined already.              In the end, it would look like this:                  $autoloader = new Zend_Application_Module_Autoloader(array(                     'namespace' => 'Default_',                     'basePath'  => MODULE_PATH,                 ));              and that's it.                    Into a controller plugin in am making use of resource autoloader this way:                  $plugins = new Default_Model_Plugins();                   Now here are my questions:                 1. Why i am receiving this error:                  Warning: include(D:\_Work\site/application/modules/models//Plugins.php) [                 function.include]: failed to open stream: No such file or directory in D:\_Work                 \site\library\incubator\Zend\Loader\Autoloader\Resource.php on line 173                  I am not sure why is not included the "default" into path... Or anyway, what i                 am missing ?               First, getting rid of the Zend_Loader::registerAutoload() will likely             take care of this. Second, use Zend_Loader from current trunk, as it has             a few changes that make it work better with autoloading.                    2. There is any other error ? Like namespace been 'namespace'   => 'Default'                 or  'namespace'   => 'Default_', as according to sample from incubator file                 ('namespace' => 'Stuff_').               I need to change that in the docblock -- no '_' suffix necessary with             resource autoloaders. The reason is that with resource autoloading,             we're making an assumption that the classes follow ZF coding standards             -- so the '_' is implied. (Zend_Loader_Autoloader, however, does require             the explicit '_' so that we can allow interop with autoloaders from             projects that do not follow the same conventions).                    3. How should be the class name of the model ? Plugins ? Or Default_Plugins ?                 or Default_Model_Plugins ?               Default_Model_Plugins. Rule of thumb: the namespace you use is the first             segment, the resource type is the second segment, and then the class             name is the last.              /me makes a note to write documentation soon!              --         Best regards,         Cristian Bichis         www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com           
   


--  Best regards, Cristian Bichis www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com