Tutorial :Zend Framework: Finding the path to the root of the application


in zend framework, i usually setup vhosts so that i can refer to my static resources like js, css via "/css/styles.css" but what if i dont setup vhosts? my path to the static resources will be like "http://localhost/app1/css/styles.css". is there a way to find find what is the proper path to css/styles.css without hardcoding the "prefix" http://localhost/app1/? if done properly, i shld be able to move my app from http://localhost/app1 to http://localhost/a/deeper/path/app2/


You need the BaseUrl View-Helper

<?php echo $this->headLink()->appendStylesheet($this->baseUrl('/css/global.css')) ?>  


<?php echo $this->headLink()->appendStylesheet('/css/global.css') ?>  

is how I set mine up. Make sure the appropriate corresponding paths are set in the index.php and config.ini. See the Zend Framework quickstart for more information if necessary.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »