On 22 Oct 2008, at 12:03, Giovanni A. D. wrote:

Hello,
I'm a zend framework noob and I'd like to understand a couple of
things that are not clear to me yet. I've read the quickstart
documentation document on how to setup the framework and I've also
learned how to do it using zend tool but the documentation always uses
absolute paths so I'd like to which is the best way to achieve this:

- having the website not on the web root (on my local apache I've it
like /test/zend/my_test/test01/ ...)


I work like this on my local dev box too. The urls I have are of the form http://localhost/project_name/public as you need to navigate to the public directory yourself in the browser.

For this to work, my .htaccess file is set up like this:

        RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule .* index.php


Note that there is no leading / on the RewriteRule line.


You also need to ensure that all the urls you create include the baseUrl from the request object. For CSS/JS/IMG files, the easiest way is to create a view helper called baseUrl() that looks like this:

        class Zend_View_Helper_BaseUrl
        {
            function baseUrl()
            {
                $fc = Zend_Controller_Front::getInstance();
                return $fc->getBaseUrl();
            }
        }


Then, for any links within the app, always use the url() view helper (or the _redirector action helper within a controller action).


All will now work as you expect and will work exactly the same if you then deploy to a vhost where the DocumentRoot is set to the public directory.


You can see an example of this working in the tutorial at http://akrabat.com/zend-framework-tutorial as I wrote it with the assumption that you wouldn't want to go to the hassle of setting up a new vhost just to test out ZF. Just don't deploy to a live server like this :)


- having the library folder outside my project (just make a symbolic
link or better to change config files?)


I have multiple copies of ZF - one per project in the lib directory as some projects may be on 1.0 and others one 1.5 and still others on 1.6. Another solution is to have one copy of ZF and set up the include_path setting in the main php.ini to point at it.

Regards,

Rob...

Reply via email to