Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set up Zend Route to use an additional 'parameter' prior to the MVC paramters?
    primarykey
    data
    text
    <p>My situation is this: The application I'm working on uses the sub-domain to detect 'who' the client is. ie: client1.site.com, client2.site.com That's all working fine (and I'm not using any special routes).</p> <p>Now however, I have a need to put my code into a 'test' environment. In this case though, I'm restricted to a single subdomain. ie: <em>static.testsite.com</em></p> <p>My thought was to use Zend Routing to a degree so that I can convert the Request as follows: <strong><em>static.testsite.com/client1/...</em></strong> or <strong><em>static.testsite.com/client2/...</em></strong></p> <p>So the first 'parameter' needs to be the client name followed by the standard MVC parameters (module/controller/action).</p> <p>I plan to add this Routing logic to the routeStartup hook of a Controller Plugin only available in the test environment.</p> <p>First, is there an easier way to accomplish this job that I haven't thought of? Second, if not, does anyone have any experience with this sort of requirement?</p> <p>I'm at the moment experimenting with the different routes that Zend provide but thus far, I've been unsuccessful (the client name keeps becoming the controller, etc).</p> <p>Any help is much appreciated. Thank you.</p> <p>Edit: I tried doing this in an ugly way by manipulating the request uri of the request object. However, this leaves the rest of the site without the /clientX/ portion in their urls thus causing further issues. And updating all locations with the /clientX/ portions is not really feasible either. So though I can retrieve the client, the rest of the site remains non-functional which makes me think that a Route is the only way.</p> <p>Edit #2: I got it working with the following code;</p> <pre><code>// within a Controller Plugin at routeStartup $oFrontController = Zend_Controller_Front::getInstance(); $oRouter = $oFrontController-&gt;getRouter(); $oNewDefaultRoute = new Zend_Controller_Router_Route( ':testClient/:controller/:action/*', array( 'module' =&gt; 'default', 'controller' =&gt; 'index', 'action' =&gt; 'index', 'testClient' =&gt; null, ) ); $oRouter-&gt;addRoute('default', $oNewDefaultRoute); </code></pre> <p>The problem remained however, since it doesn't affect any of the existing urls. So trying to access any of them leads to a place without the testClient thus causing errors. I believe some session based solution following the initial 'client' assigning will need to be adopted.</p> <p>If however, someone knows of a more elegant way to do it, do let me know. Thank you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload