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).
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: static.testsite.com
My thought was to use Zend Routing to a degree so that I can convert the Request as follows: static.testsite.com/client1/... or static.testsite.com/client2/...
So the first 'parameter' needs to be the client name followed by the standard MVC parameters (module/controller/action).
I plan to add this Routing logic to the routeStartup hook of a Controller Plugin only available in the test environment.
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?
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).
Any help is much appreciated. Thank you.
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.
Edit #2: I got it working with the following code;
// within a Controller Plugin at routeStartup
$oFrontController = Zend_Controller_Front::getInstance();
$oRouter = $oFrontController->getRouter();
$oNewDefaultRoute = new Zend_Controller_Router_Route(
':testClient/:controller/:action/*',
array(
'module' => 'default',
'controller' => 'index',
'action' => 'index',
'testClient' => null,
)
);
$oRouter->addRoute('default', $oNewDefaultRoute);
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.
If however, someone knows of a more elegant way to do it, do let me know. Thank you.
Ini-based solution suggestion, untested - just for general idea:
routes.withClient.route = ":client/:module/:controller/:action/*"
routes.withClient.defaults.module = "default"
routes.withClient.defaults.controller = "index"
routes.withClient.defaults.action = "index"
Value of client
accessible through $request->getParam('client')
.