2008年9月11日星期四

Re: [fw-mvc] Using MVC with $_GET instead mod_rewrite

You should read http://akrabat.com/2008/06/03/zend-framework-urls-without-mod_rewrite/

Julien.P

2008/9/11 Emanuele Deserti <emanuele.deserti@netwing.it>
I use a custom Request class with URL like this:

http://example.com/index.php?p=module/controller/action/key1/value1/key2/value2 etc...

This is the code (with stripped comments) of my Custom/Controller/Request/Pvariant.php:

<?php

/** Zend_Controller_Request_Exception */
require_once 'Zend/Controller/Request/Exception.php';

/** Zend_Controller_Request_Http */
require_once 'Zend/Controller/Request/Http.php';

/** Zend_Uri */
require_once 'Zend/Uri.php';

class Custom_Controller_Request_Pvariant extends Zend_Controller_Request_Http
{
   protected $_pathKey = 'p';

   public function setPathKey($key)
   {
       $this->_pathKey = (string) $key;
       return $this;
   }

   public function getPathKey()
   {
       return $this->_pathKey;
   }

   public function setPathInfo($pathInfo = null)
   {
       parent::setPathInfo($pathInfo);
       if (isset($_GET[$this->_pathKey])) {
           $this->_pathInfo = (string) $this->_pathInfo . $_GET[$this->_pathKey];
       }
       return $this;
   }

}

?>

and then, in bootstrap.php, before dispatch

$request = new Custom_Controller_Request_Pvariant();
$front->setRequest($request);

Maybe this method was not the best way (for sure was not the best way) but it's the only practicable that I have found without mod_rewrite and with the minimum effort...



Is it possible to set up Zend MVC without using mod_rewrite, like this:

http://example.com/index.php?controller=myController&method=myMethod

Where do I start?

regards, Jan
--
View this message in context: http://www.nabble.com/Using-MVC-with-%24_GET-instead-mod_rewrite-tp19431142p19431142.html
Sent from the Zend MVC mailing list archive at Nabble.com.


---
Emanuele Deserti
Netwing S.r.l.
<emanuele.deserti@netwing.it>
Tel. 0532-1915183
http://www.netwing.it


没有评论: