I am new to Zend Framework, trying to config project on my local for further changes. I succesfully installed and configured Zend Framework. But CSS is not working. Could anybody help me please?
basically, in 'yourProject/application/layout/layout.phtml', put the following line in the head section of your html :
<?php $this->headLink()->appendStylesheet('/css/style.css') ?>
now Zend will look for the file 'yourProject/public/css/style.css'
Kind of a vague question. If your application is running fine under http://domain.com/, but CSS and other externals don't work under http://domain.com/project/, it's probably an issue with your external resource paths. Are you trying to load the resources with a fully qualified path (starts with a '/'), or a relative path (no '/' in the beginning)?
Full paths, such as '/css/style.css', will not work as expected if the application moves, say from http://domain.com/ to http://localhost/project/public/. This is because the browser will always look for the resource at the site root - http://domain.com/css/style.css and http://localhost/css/style.css in our example.
Relative paths, such as 'css/style.css', will work as expected under both URLs, but may not work correctly when you start adding other virtual paths to the URL. To continue the example, a relative URL will cause the browser to look for http://domain.com/css/style.css and http://localhost/project/public/css/style.css. The caveat is that the page at http://localhost/project/public/controller/action will generate relative resource URLs like http://localhost/project/public/controller/action/css/style.css, which won't work.
To get external resources to load in both situations, use a BASE tag in your layout and use relative URLs for external resources. I tend to use the following:
<head>
<base href="<?php echo $this->serverUrl($this->baseUrl()); ?>/">
</head>
The BASE tag forces the specified prefix to all relative URLs, which will make the page at http://localhost/project/public/controller/action generate relative URLs like http://localhost/project/public/css/style.css.
Hopefully that makes sense, but the short version is to try using a BASE tag if your application needs to run in any arbitrary location.
Ah! I got its working We have to change Local Path in Home Directory to C:\Inetpub\wwwroot\project\public and i was using just C:\Inetpub\wwwroot\ thats why css was not working
Thanks to all for your answers and comments
You don't have to configure the base-tag.
Simply use the baseUrl()-view helper whenever you link to external resources like so:
<?php $this->headLink()->appendStylesheet($this->baseUrl('/css/style.css')) ?>