Nov 12 2010

Use Zend Framework in subfolder

What do you need to do? Nothing! Put it in a subfolder.

Trying to find the awnser on the question: “How do you use Zend Framework in a subfolder” a lot of resources I found referred to an article on Alexander Netkachev’s blog. At the time of writing Alex is reviewing all of his articles, so I had to figure this out one myself. Hopefully Alex’s article will be online anytime soon. I’m sure it contains valuable information. However, I guess it is not the information I was looking for. On Zend Devzone Carl Evans refers to Alex’s article and the 2 solutions found by Alex. He quotes the opening paragraph, revieling some information about 2 provided solutions in the last few lines:

First is rather a hack then a recommended solution, but with it you can start the applications and examples that use standard router. The second is neater but it depends on the Zend_Controller_RewriteRouter class.

A hack? Depends on the router? Not sure we are adressing the same problem here. Maybe his solution is for people having no access to the directory above the public directory. I don’t know. My solution is almost to easy. It only needs minor editing of index.php. Off course there is are some caveats.

Firstly I will make clear what we are talking about here. What is the folder structure we are creating? Next I will show you how to put your Zend Framework in a subfolder. Be sure to also read the conditions to be met when using this solution. As you might expect, these are mainly about links to pages and resources inside your own domain. The Zend View Helpers BaseUrl and Url are key to our solution. Continue reading