views:

45

answers:

2

Hi,

I developed a application with Zend Framework and now I want to be able to place the app in an subdirectory of a Documentroot. e.g. http://www.example.com/myapp/

I read quite a lot of Docu how this could work, but all in all these solutions don´t fit my needs. Is there a trivial way to do the subdir thing, without adding the concrete path to any file which generates the pages.

There are some examples in the net, where a basePath is set in the application enviroment and so there is a method call bevor each "form" creation which prepends the path before the link.

$form->setAction($this->_request->getBaseUrl() . $this->_helper->url('sign'));

This was from: http://johnmee.com/2008/11/zend-framework-quickstart-tutorial-deploy-to-a-subdirectory-instead-of-web-root/

But this is only works for small examples, I have tons of forms, tons of views and tons of scripts. I can´t belive this (lets call it hack :) ) is the only solution to do this.

Any ideas?

+2  A: 

As they say on the web page:

I’m told this last issue has been lodged has a defect and not necessary from releases “1.7″ and beyond. The helper->url will henceforth prepend the baseUrl to its result.

So you should be fine. Do you actually use the $form->setAction() method on every form already? Because if you use it in combination with the url helper, the baseUrl will already be included.

Sebastian Hoitz
I have to confess I'm doing this not till. But I will give it a shot.Thx
evildead
+2  A: 

You don't have to do anything special. See my tutorial at http://akrabat.com/Zend-framework-tutorial which is developed entirely within a sub-directory.

Rob Allen
oh well, but you are referencing always the complete path zf-tutorial/public, I itentionly do not want that. I want just example.com/app/myaction, example.com/app/myaction2 and so on, so the path public is transparent. You are using the ->getBaseUrld()-Thing too, mybe there is no other way.Btw your tutorials are great. Helped me a lot wa while ago. Thx in advance
evildead
Ah! In that case, move index.PHP to the my app directory...See http://akrabat.com/zend-framework/zend-framework-on-a-shared-host/ for some ideas.
Rob Allen
ok good idea, I will try that later. Thx.
evildead