Using Zend Framework with interactive consoles

7 messages Options
Embed this post
Permalink
Jules Piccotti

Using Zend Framework with interactive consoles

Reply Threaded More More options
Print post
Permalink
Hi, does everyone has any experience on using ZF with any of the  
interactive console?

I tested some of the most populars:
- plain "php -a"
- phpsh, a Python iplementation open sourced by Facebook: http://www.phpsh.org/
- PHP-Shell, my favourite, which is the only one capable of handling  
fatal errors - indispensable for debugging: http://pear.php.net/package/PHP_Shell/

Unfortunately, they all seems to fail when it comes to autoloading...  
In particolar the standard PHP interactive mode is fully documented as  
not compatible with autoload: http://www.php.net/manual/en/language.oop5.autoload.php

Does anybody knows of a valid alternative, or a workaround to make one  
of these work seamlessy with ZF applications?

Also, if you start testing it, please notice that usage of the  
__FILE__ magic constant will break your application: while in  
interactive console it points to the executable position (probably usr/
local/bin or something similar) and not your executed php script.

Jules Piccotti
tprinty

Router Help?

Reply Threaded More More options
Print post
Permalink
Hello,

I am trying to get some routes to work and having some troubles


I have a couple routes defined like:


$router->addRoute(
        'index',
        new Zend_Controller_Router_Route(
                '/:city/:state/:keyword/',
                array('controller' => 'index',
                      'action' => 'index'
                )
        )
);

//add the route
$controller = Zend_Controller_Front::getInstance();
$controller->setRouter($router);



However when I try the URL
http://example.com/elgin/il/garage/

I get the following dump
#0 library/Zend/Controller/Front.php(946):
Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#1 /library/Zend/Application/Bootstrap/Bootstrap.php(77): Zend_Controller_Front->dispatch()
#2 /library/Zend/Application.php(358): Zend_Application_Bootstrap_Bootstrap->run()
#3 /public/index.php(26): Zend_Application->run()
#4 {main}  
Request Parameters:
array (
  'controller' => 'elgin',
  'action' => 'il',
  'garage' => 'index',
  'module' => 'default',
)  


Can anyone offer any suggestions?

Thanks
-Tom Printy

prodigitalson

Re: Router Help?

Reply Threaded More More options
Print post
Permalink
Try adding the module to your default paramters:

$router->addRoute(
        'index',
        new Zend_Controller_Router_Route(
                '/:city/:state/:keyword/',
                array('controller' => 'index',
                      'action' => 'index',
                      'module' => 'default'
                )
        )
);


tprinty wrote:
Hello,

I am trying to get some routes to work and having some troubles


I have a couple routes defined like:


$router->addRoute(
        'index',
        new Zend_Controller_Router_Route(
                '/:city/:state/:keyword/',
                array('controller' => 'index',
                      'action' => 'index'
                )
        )
);

//add the route
$controller = Zend_Controller_Front::getInstance();
$controller->setRouter($router);



However when I try the URL
http://example.com/elgin/il/garage/

I get the following dump
#0 library/Zend/Controller/Front.php(946):
Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#1 /library/Zend/Application/Bootstrap/Bootstrap.php(77): Zend_Controller_Front->dispatch()
#2 /library/Zend/Application.php(358): Zend_Application_Bootstrap_Bootstrap->run()
#3 /public/index.php(26): Zend_Application->run()
#4 {main}  
Request Parameters:
array (
  'controller' => 'elgin',
  'action' => 'il',
  'garage' => 'index',
  'module' => 'default',
)  


Can anyone offer any suggestions?

Thanks
-Tom Printy
tprinty

Re: Router Help?

Reply Threaded More More options
Print post
Permalink
Hi,

Thanks for the reply as you can see in the request params it figures out
the right module. It really goofs up the controller and action though.

Request Parameters:
array (
        'controller' => 'elgin',
        'action' => 'il',
        'garage' => 'index',
        'module' => 'default',
)


On Wed, 2009-10-28 at 13:25 -0700, prodigitalson wrote:

> Try adding the module to your default paramters:
>
> $router->addRoute(
> 'index',
> new Zend_Controller_Router_Route(
> '/:city/:state/:keyword/',
> array('controller' => 'index',
>      'action' => 'index',
>                       'module' => 'default'
> )
> )
> );
>
>
>
> tprinty wrote:
> >
> > Hello,
> >
> > I am trying to get some routes to work and having some troubles
> >
> >
> > I have a couple routes defined like:
> >
> >
> > $router->addRoute(
> > 'index',
> > new Zend_Controller_Router_Route(
> > '/:city/:state/:keyword/',
> > array('controller' => 'index',
> >      'action' => 'index'
> > )
> > )
> > );
> >
> > //add the route
> > $controller = Zend_Controller_Front::getInstance();
> > $controller->setRouter($router);
> >
> >
> >
> > However when I try the URL
> > http://example.com/elgin/il/garage/
> >
> > I get the following dump
> > #0 library/Zend/Controller/Front.php(946):
> > Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http),
> > Object(Zend_Controller_Response_Http))
> > #1 /library/Zend/Application/Bootstrap/Bootstrap.php(77):
> > Zend_Controller_Front->dispatch()
> > #2 /library/Zend/Application.php(358):
> > Zend_Application_Bootstrap_Bootstrap->run()
> > #3 /public/index.php(26): Zend_Application->run()
> > #4 {main}  
> > Request Parameters:
> > array (
> >   'controller' => 'elgin',
> >   'action' => 'il',
> >   'garage' => 'index',
> >   'module' => 'default',
> > )  
> >
> >
> > Can anyone offer any suggestions?
> >
> > Thanks
> > -Tom Printy
> >
> >
> >
>

prodigitalson

Re: Router Help?

Reply Threaded More More options
Print post
Permalink
Well its going to fail over to the default module but i think by *BOTH* not specifying and not including it in the route pattern its not matching the route to the route you expect - its failing over to the default module route which assumes the pattern :module/:controller/:action/*

Also, and this maybe the only thing wrong... routes Should not have a leading slash. hope that helps.

tprinty wrote:
Hi,

Thanks for the reply as you can see in the request params it figures out
the right module. It really goofs up the controller and action though.

Request Parameters:
array (
        'controller' => 'elgin',
        'action' => 'il',
        'garage' => 'index',
        'module' => 'default',
)


On Wed, 2009-10-28 at 13:25 -0700, prodigitalson wrote:
> Try adding the module to your default paramters:
>
> $router->addRoute(
> 'index',
> new Zend_Controller_Router_Route(
> '/:city/:state/:keyword/',
> array('controller' => 'index',
>      'action' => 'index',
>                       'module' => 'default'
> )
> )
> );
>
>
>
> tprinty wrote:
> >
> > Hello,
> >
> > I am trying to get some routes to work and having some troubles
> >
> >
> > I have a couple routes defined like:
> >
> >
> > $router->addRoute(
> > 'index',
> > new Zend_Controller_Router_Route(
> > '/:city/:state/:keyword/',
> > array('controller' => 'index',
> >      'action' => 'index'
> > )
> > )
> > );
> >
> > //add the route
> > $controller = Zend_Controller_Front::getInstance();
> > $controller->setRouter($router);
> >
> >
> >
> > However when I try the URL
> > http://example.com/elgin/il/garage/
> >
> > I get the following dump
> > #0 library/Zend/Controller/Front.php(946):
> > Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http),
> > Object(Zend_Controller_Response_Http))
> > #1 /library/Zend/Application/Bootstrap/Bootstrap.php(77):
> > Zend_Controller_Front->dispatch()
> > #2 /library/Zend/Application.php(358):
> > Zend_Application_Bootstrap_Bootstrap->run()
> > #3 /public/index.php(26): Zend_Application->run()
> > #4 {main}  
> > Request Parameters:
> > array (
> >   'controller' => 'elgin',
> >   'action' => 'il',
> >   'garage' => 'index',
> >   'module' => 'default',
> > )  
> >
> >
> > Can anyone offer any suggestions?
> >
> > Thanks
> > -Tom Printy
> >
> >
> >
>
tprinty

Re: Router Help?

Reply Threaded More More options
Print post
Permalink
In reply to this post by tprinty
Hello,

I got my route to work however If  I add two routes to a controller only
the last one added is evaluated. Is this the intended behavior?

Thanks
-Tom Printy


Tom Printy wrote:

> Hello,
>
> I am trying to get some routes to work and having some troubles
>
>
> I have a couple routes defined like:
>
>
> $router->addRoute(
> 'index',
> new Zend_Controller_Router_Route(
> '/:city/:state/:keyword/',
> array('controller' => 'index',
>      'action' => 'index'
> )
> )
> );
>
> //add the route
> $controller = Zend_Controller_Front::getInstance();
> $controller->setRouter($router);
>
>
>
> However when I try the URL
> http://example.com/elgin/il/garage/
>
> I get the following dump
> #0 library/Zend/Controller/Front.php(946):
> Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
> #1 /library/Zend/Application/Bootstrap/Bootstrap.php(77): Zend_Controller_Front->dispatch()
> #2 /library/Zend/Application.php(358): Zend_Application_Bootstrap_Bootstrap->run()
> #3 /public/index.php(26): Zend_Application->run()
> #4 {main}  
> Request Parameters:
> array (
>   'controller' => 'elgin',
>   'action' => 'il',
>   'garage' => 'index',
>   'module' => 'default',
> )  
>
>
> Can anyone offer any suggestions?
>
> Thanks
> -Tom Printy
>
>  

Peter Warnock-2

Re: Router Help?

Reply Threaded More More options
Print post
Permalink
On Mon, Nov 2, 2009 at 6:36 AM, Tom Printy <[hidden email]> wrote:
Hello,

I got my route to work however If  I add two routes to a controller only the last one added is evaluated. Is this the intended behavior?

 
Do your routes have unique names? - pw