Dynamic CSS/Javascript in Twig using Silex/SilexExtensions and Assetic Dynamic CSS/Javascript in Twig using Silex/SilexExtensions and Assetic php php

Dynamic CSS/Javascript in Twig using Silex/SilexExtensions and Assetic


Since (you mention) the properties in the less file can change per request, I think you're missusing assetic (and maybe even less). It sounds like you're trying to use assetic as a less preprocessor, which it's not + there's little reason to cache the result (this depends on how often they will actually differ per request).

You don't get into much detail about what you want to achieve, but I tuess it's something like a theming engine, where users can change their color scheme (and other appearance variables). If this is the case, I think you should put the bulk of your CSS/less files in one template, common for all requests, and then have a route in your silex app to deliver the theme-specific css with variables from the DB.

Since they can be different per request, I don't think there's a reason to add less preprocessing overhead on the server for each request, so you should output straight CSS. At most, you could let the client process the .less files, if you're comfortable with that.