开发者

zend framework under document root in subdir

开发者 https://www.devze.com 2023-01-10 02:13 出处:网络
I developed a application with Zend Framework and now I want to be able to place the app in an subdirectory of a Documentroot.

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?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号