views:

50

answers:

1

I am trying to integrate Wordpress with my Zend application using a plugin and it is working quite well except for one thing: the base url. My wordpress plugin calls my integration function inside my application's bootstrap from /myapplication/libray/wordpress. Therefore, the request base url is set to this value for the entire application. I would like to fool Zend into thinking that the request was dispatched from /myapplication/public so that it can detect the base url accordingly. Of course, $request->setBaseUrl('/myapplication/public') would be the easy way, but that would bug me on the production side where the blog will be hosted on blog.myapplication.com and where the base url will be mapped to / and will not pose problem. I don't want to hack around and put conditionals based on application environment.

Is there an elegant way to do this. I tried playing around with the request object and $_SERVER variables such as REQUEST_URI, SCRIPT_NAME SCRIPT_FILENAME PHP_SELF but I can't seem to be able to make it work. Maybe I need to use a Route object, and if so, could someone explain me how since I don't seem to have the greatest grasp on understanding the concept in this situation.

+1  A: 

Why not do your $request->setBaseUrl() trick based on the APPLICATION_ENV constant?

if (APPLICATION_ENV != 'production') {
  $request->setBaseUrl('/myapplication/public'); 
}

Or better yet - set up virtual hosts on your development machine to mimic the actual production setup.

gnarf
Well that is actually exactly what I did as an alternative approach even though I am not absolutely pleased with this approach. But I guess this is the most simple solution so far without adding unnecessary complexity.
Steven Rosato
@gnarf All in all I think it came to that solution after all. Better using that approach than nothing.
Steven Rosato