views:

847

answers:

2

I'd love to use PHP variables in my CSS files but I don't want to load up the whole Symfony stack for each file load. Any one have any best practices and/or plugins to manage their CSS files in Symfony?

+1  A: 

Here's one good Plugin that tries to manage and/or combine your assets:

http://www.symfony-project.org/plugins/sfCombinePlugin

Here's their description:

Combines multiple JavaScript and CSS files into one JavaScript and one CSS file at runtime, in order to minimize the number of HTTP requests required to render a given page. This plugin works in distributed environments, supports asset version keys, and is highly customizable.

Also, since it's compiled, you may be able to use simple PHP as long as the variables stick within the same file.

thrashr888
+3  A: 

but you dont need full symfony stack for that ( except if you need some internal symfony state / variable ).

You just use

<link rel="stylesheet" type="text/css" media="screen" href="/css/mycss.php" />

and then you can use php inside your css. you could add appropriate headers (text/css) with header in php.

deresh
i was assuming the .htaccess and routing would try to run the symfony stack but you're right, it'll just hit whatever file is in there. thanks!
thrashr888