Using the Zend framework implies a radical change in the way we usually handle the file structure of our projects. In fact, the Zend framework is based on a strict separation between the core application files and your front-end files, where front-end files means the files that will be served to web browsers. In older versions of PHP web applications, that is, prior to Zend and the MVC design pattern, the file hierarchy was basically contained within the document root of your web server. Supposing that your document root is called public_html
, then the old hierarchy was something like the following:
/public_html /app index.php /assets .htaccess
With the Zend framework, all the application core files and directories are put outside the document root:
/sitename /app /public_html index.php .htaccess /assets
Of course if you're on a shared host, you won't probably have access to the upper level of your site directory structure, so you're forced to put everything within the document root. In this case, I recommend you to beef up your security controls in order to prevent malicious users from accessing your core application files.
In either case, using an MVC system implies that you should modify your base PHP include path sooner or later. Why so? Because if you don't do so, you'll probably stumble on some annoying PHP errors claiming that a given file or resource was not found due to your include path settings. There are several ways to do accomplish this task:
- using the
set_include_path()
function:<?php $path = '/usr/lib/pear'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); ?>
- using the
.htaccess
file - using the same technique described for the
.htaccess
file on yourhttpd.conf
Apache configuration file within aDirectory
rule block.
Obviously not all the aforementioned techniques can be actually applied, especially when you don't have full access to your web server. Always check out what option is best for you.