Results 1 to 2 of 2

Thread: Using zend without mod rewrite

  1. #1
    fuzz is offline Junior Member
    Join Date
    Sep 2011
    Posts
    1

    Default Using zend without mod rewrite

    Hi
    I would like to use Zend without mod rewrite
    I would like to use usrl like : site.com?process=bla&user=bla

    any suggestion which is the best way to accomplish this ?

    Thaks

    Fuzz

  2. #2
    shadowfax is offline Junior Member
    Join Date
    Mar 2012
    Posts
    10

    Default

    Hi Fuzz,

    I've done this by extending a router. As a Step by step of what I did:

    First create, if not already created, a path in your libraries file to extend your zend configuration; for example ZendExt.

    Inside this folder create a subfolder named Controller and now create a new php called Router.php.
    The content of this file would be something like:

    Code:
    class ZendExt_Controller_Router extends Zend_Controller_Router_Abstract implements Zend_Controller_Router_Interface
    {
        public function route(Zend_Controller_Request_Abstract $request)
        {
            $module = '';
            if(isset($_GET['module'])) {
                $controller = $_GET['module'];
            }
            $request->setModuleName($module);
            
            $controller = 'index';
            if(isset($_GET['controller'])) {
                $controller = $_GET['controller'];
            }
    
            $request->setControllerName($controller);
    
            $action = 'index';
            if(isset($_GET['action'])) {
                $action = $_GET['action'];
            }
    
            $request->setActionName($action);
        }
        
        public function assemble($userParams, $name = null, $reset = false, $encode = true)
        {}
    }
    Keep in mind the name of the class should be the same as the path to the class changing "/" for "_".

    Now, set an autolloader for your classes in the application.ini:

    Code:
    autoloaderNamespaces.extension[] = "ZendExt_"
    Finally go into the Bootstrap (/application/Bootstrap.php) and load your router. For example:

    Code:
    class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
    {
        ...
    
        /**
        * Bootstrap Router
        */
        protected function _initRouter()
        {
            $this->bootstrap('frontController');
            $frontController = $this->getResource('frontController');
    
            $frontController->setRouter(new ZendExt_Controller_Router());
        }
        
        ...
    }
    ...and you're ready to go.

    By the way, make changes to the router so it takes the parameters you wish to take and assign them to the proper variables.

    Cheers

Posting Permissions

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