I’m finally delving in to CSS Preprocessing, and trying to figure out the best route to go. My primary questions are:
- What is the value of using SASS or LESS over Php?
- If I were to use SASS or LESS, what’s the best way to integrate values from the database?
Obviously using php to print styles in the header is a pretty bad idea. I was using php to create a stylesheet, and importing it as ‘Content-Type: text/css’. It would then create the stylesheet that would be served as such and cached properly. I could use values from the database and work with the language I’m already adept with.
What advantages do SASS and LESS have over Php for creating/working with the stylesheets, and if I were using them, what is the best way to use values from the database? Would I need to use Php to grab the values from the database, basically continuing my methods above, only for that use, then using SASS, LESS, or another to work with the rest of the stylesheet?
Thank you very, very much for your help!
CSS preprocessors like SASS and LESS give you much more than just serving a PHP (or any other server side language) file with dynamic code, served with a
content-type:text/cssThey give you:
To do all that in PHP by yourself would be a fair effort!
Regarding getting data from a database and using it in your SASS / LESS, it’s not something that preprocessors would allow you to do out of the box. You could write your own PHP code that would read from a database, collect the information and values you need, and then write a SASS or LESS file to the filesystem using these values. You could just write a normal CSS file too if you don’t need the features above that preprocessors give you.