+ Reply to Thread
Results 1 to 5 of 5

Thread: not ableto configure router in bootstrap file :-(

  1. #1
    jameel.j2ee is offline Junior Member
    Join Date
    Oct 2008
    Posts
    9

    Default not ableto configure router in bootstrap file :-(

    I am trying to set up the router (Zend_Controller_Router_Route) in my application's bootstrap file. Its so strange that, my IDE (PHPeD) doesnt show addRoute as a method of router. When I run, my application, I get following error:

    Fatal error: Cannot use object of type Zend_Controller_Router_Route as array in E:\Softwares\Apache2.2.6\htdocs\ZendProj\library\Z end\Controller\Router\Route.php on line 247


    This is how I am trying to setup the router for my application.

    Code:
    $router = $frontController->getRouter();
    
    $router = new Zend_Controller_Router_Route('signup/:uid/*',array('module'=>'signup',
                                                                     'controller'=>'signup',
                                                                     'id' =>null),
                                                                     array('id'=>'(.*)'));
    
    $router->addRoute('signup',$route);

    I am using ZendFramework-1.6.1

    Is there anything I am missing?

    Can anyone pls help me into this?

    Thanks a lot

    regards
    Jameel

  2. #2
    weierophinney is offline Junior Member
    Join Date
    Oct 2008
    Location
    Richmond, VT, USA
    Posts
    2

    Default Overwriting existing variable.

    The problem is here:
    [PHP]
    $router = $frontController->getRouter();
    $router = new Zend_Controller_Router_Route(...);
    [/PHP]
    You're overwriting the $router variable in the second line. Simply change it to $route, and you should be fine.

  3. #3
    jameel.j2ee is offline Junior Member
    Join Date
    Oct 2008
    Posts
    9

    Default URL generation problem

    Thanks Matthew, for pointing that out to me :-)

    basically I am trying to generate URL like /controllername/actionname/parameter1/value1/parameter2/value2

    While I have been able to configure the router in my Bootstrap file as follws :

    Code:
    ——————————————————————–
    $router = $frontController->getRouter();
    
    $route = new Zend_Controller_Router_Route(’signup/:uid/*’,array(’module’=>’signup’,
    ‘controller’=>’signup’,
    ‘id’ =>null),
    array(’id’=>’(.*)’));
    
    $router->addRoute(’signup’,$route );
    ——————————————————————–
    and from my controller's action method (SignupController.php->indexAction), I am trying to generate URL as follows :

    Code:
    $URL = $this->url(array(
    ‘controller’ => ‘user’,
    ‘action’ => ‘edit’,
    ‘id’ => ‘123′
    ));
    When I run my application I am getting following error :

    exception ‘Zend_Controller_Action_Exception’ with message ‘Method “url” does not exist and was not trapped in __call()’ in E:SoftwaresApache2.2.6htdocszendProjlibraryZendCon trollerAction.php:481 Stack trace: #0 [internal function]: Zend_Controller_Action->__call(’url’, Array) #1 E:SoftwaresApache2.2.6htdocszendProjapplicationcon trollersSignupController.php(59): SignupController->url(Array) #2 E:SoftwaresApache2.2.6htdocszendProjlibraryZendCon trollerAction.php(502): SignupController->indexAction() #3 E:SoftwaresApache2.2.6htdocszendProjlibraryZendCon trollerDispatcherStandard.php(293): Zend_Controller_Action->dispatch(’indexAction’) #4 E:SoftwaresApache2.2.6htdocszendProjlibraryZendCon trollerFront.php(946): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #5 E:SoftwaresApache2.2.6htdocszendProjpublicindex.ph p(92): Zend_Controller_Front->dispatch() #6 {main}

    I am following Naneau Use the URL view helper, please



    Thanks
    Jameel

  4. #4
    ascen is offline Junior Member
    Join Date
    Sep 2008
    Posts
    8

    Default

    Quote Originally Posted by jameel.j2ee View Post
    When I run my application I am getting following error :

    exception ‘Zend_Controller_Action_Exception’ with message ‘Method “url” does not exist and was not trapped in __call()’ in
    ... <snip/>

    I am following Naneau Use the URL view helper, please
    The exception you are getting is due to the fact that your controller cannot access the view helper - thus the error. (__call() is PHP magic function invoked when the class does not have the function you tried to call).

    View Helpers are supposed to be called from within the view (that is, view scripts at the default ZF layout). Move your $this->url($options_array, $routename) there and you get rid of the exception.

    Another issue with your code is that you do not pass the route name to the url helper:

    Code:
    $router->addRoute(’signup’,$route );
    ——————————————————————–
    Code:
    $URL = $this->url(array(
    ‘controller’ => ‘user’,
    ‘action’ => ‘edit’,
    ‘id’ => ‘123′
    ));
    Change that to include the route you want to use and it should work out fine.
    Code:
    $this->url($options_array, 'signup');

  5. #5
    jameel.j2ee is offline Junior Member
    Join Date
    Oct 2008
    Posts
    9

    Default How to pass values from once action to another in the same controller?

    Well, may be I have not been able to explain my problem properly.

    I am trying to save some data (basically registration data) to the database. Once that is successfully saved into the db, I am trying to forward the user to the new action as follows :

    Code:
    /** Generate unique profile Id and save it to DB along with user's registration     details.
    *      Once data is properly saved in to the db, forward the user's       
     *    control to register1 Action (defined in the same controller)
    */
    
    $this->_forward('register1');
    Now this works perfectly fine. Apart from this what I also want is, to pass on unique profile Id of the user which was generated above.

    Reason I want to pass this unique profile Id from one action to another is that, I have to use this unique profile Id into the 2nd action (register1)

    Also as you have mentioned that, viewhelpers are something which I can use it only from the views (i.e phtmls). What does Zend has to offer for the above requirement (i.e if I have to pass the values to other actions[in the same controller] as a URL as a parameter, how can I do that?)

    Any pointers or link to the web-resource will be of great help. I have been struggling into this since 3-4 days

    Thanks for your time and support

    Regards
    Jameel

+ Reply to Thread

Similar Threads

  1. Bootstrap file not working properly.
    By darrenl in forum Installation & Configuration
    Replies: 1
    Last Post: 05-07-2010, 08:14 PM
  2. perform redirect in bootstrap file
    By radub in forum Authentication & Authorization
    Replies: 3
    Last Post: 03-12-2010, 02:32 AM
  3. The Bootstrap - Index.php file
    By yorkshireDeveloper in forum Model-View-Controller (MVC)
    Replies: 2
    Last Post: 09-02-2008, 06:38 AM
  4. Zend_Cache bootstrap file setup?
    By conradwt in forum Core Infrastructure
    Replies: 3
    Last Post: 08-13-2008, 02:57 PM
  5. .htaccess configuration for index.php bootstrap file
    By spaze in forum Installation & Configuration
    Replies: 1
    Last Post: 05-14-2008, 02:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts