I am a front end developer and have recently considered using SASS or LESS for CSS development.
However I do not use Ruby and I don't want to rely on users having JavaScript active. Does anyone have any tips for using SASS or LESS using PHP projects?
The problem with using Sass is that it doesn't integrate nicely with PHP-based projects. Sass is written in Ruby, so everyone on the team must have Ruby installed on their development machines and then the Sass gem installed. It isn't a huge hassle, but it falls outside the project workflow.
SASS has more developer community and support than SCSS. SASS supports SassDoc to add documentation whereas SCSS allows inline documentation. SASS can't be used as CSS and vice-versa whereas a valid CSS code is also a valid SCSS code.
As part of our ongoing initiatives, we've decided to deprecate Sass, with the aim of improving the user experience of storefronts, and paving the way for future advancements. In the short term, Sass will continue to work on Shopify themes, but we are actively migrating our themes to use only CSS stylesheets.
SCSS contains all the features of CSS and contains more features that are not present in CSS which makes it a good choice for developers to use it. SCSS is full of advanced features. SCSS offers variables, you can shorten your code by using variables. It is a great advantage over conventional CSS.
Download the latest version of lessphp here.
Here is an example on how I tried it:
<?php require 'lessc.inc.php'; $less = new lessc('test.less'); file_put_contents('test.less.css', $less->parse()); ?> <html> <head> <title>Less CSS</title> <link rel="stylesheet" href="test.less.css" type="text/css" /> </head> <body> <h1>This isn't supposed to be black!</h1> </body> </html>
And my test.less file:
@color : #33ddff; .colorful(@textcolor : red){ color : @textcolor; } h1{ .colorful(@color); }
It works for me, and it's php!
You now have two options written by me:
Both are well documented. I encourage you to try them out and tell me if you have any trouble.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With