Tag cloud
See my latest projects
About this site
This site is proudly powered by WordPress. If you like what you see, why not subscribe?
Copyright © 2008-2010 Aaron Russell. All rights reserved.
Wednesday, 23 December 2009

The problem with CSS pre-processing frameworks is that they don’t really fit within the average web designers’ work flow. Or they don’t mine, anyway.
Having to compile and recompile at every iteration is just a pain in the backside, it’s not the way I work. I like to make some tweaks, view them in the browser, make more tweaks, view them in the browser, and repeat.
When you add in to that the process of going to the command line and recompiling, all of a sudden writing CSS becomes a dull slog. Not the way I like to work.
The other problem is that pre-processing frameworks are normally deeply entrenched in a particular technology, such as SASS and LESS being Ruby tools.
This is fine if you’re developing CSS within your web application, but that’s not the way I work. I like to build all my HTML and CSS assets way before I go anywhere near firing up the web app – I build simple static assets that I use later.
There are a few tools out there to help this problem with regards to SASS. My favourite is StaticMatic and there is also the popular Compass. However, my new CSS framework of choice, LESS, has fewer tools available to assist.
Yesterday afternoon I wanted to demo some LESS-based work to a client. It needed some basic dynamic functionality, but I didn’t want to faff around with setting up a Ruby project. PHP would do the trick so I needed LESS to work within PHP.
So, I spent a few hours bashing together the LESS PHP Cacher.
OK, lets be clear, this is NOT a PHP port of LESS. I’ll leave that joyous-sounding task to someone with far more PHP wizardry skills (and time on their hands) than me.
Therefore, you still need Ruby in order to install the LESS and LESS PHP Cacher gems.
First of all it installs a command line tool on your system. Using the command line tool installs a simple PHP wrapper script in to your web project.
Now you just write all your stylesheets using LESS. When you view the site in a browser, the PHP wrapper script invokes the LESS engine to parse the LESS into CSS and it creates a cached version.
That’s it.
In truth it doesn’t do a hell of a lot more than just leaving the normal LESS command line tool running in watch mode. The only difference is that you don’t have to worry about starting up daemons, you can work on multiple LESS files at once, and it might be a little bit more friendly to non-Rubyists.
The other plus point is that you can, in theory, put this on your production environment – providing you have access to the command line and can install Ruby Gems.
Whether or not you’d actually want to do that I’m not sure. I built this primarily as a development tool for my own specific needs.
As with all Ruby Gems, installation is easy:
sudo gem install less_php_cacher
It requires LESS (obviously) so make sure that’s installed too.
Hop into your command prompt and go to the root of your existing web project. Then simply type:
lessphpc prepare
That creates the PHP wrapper script (called less.php) and a cache directory.
Write your LESS-based stylesheets and save them where-ever you like within your web project. Then reference them in your source code by either:
<link rel="stylesheet" href="less.php?style.less" type="text/css">
..or..
<?php include 'less.php'; ?>
<style type="text/css">
<?php less_php('style.less'); ?>
</style>
Usual stuff – this is the result of only a few hours bodging about, and not at all tested other than on my own Mac. Mileage may vary.
That said, feel free to let me know how it goes – any problems you encounter or any new features you’re like to see included.
Last week I asked the question on Twitter, “What HTML element do you use for each line of a form? P, DIV, or something else?” So, how do you do your forms?
This years season of 24 ways article has come to a close and with it a reoccurring theme of controversy has arisen: designing in the browser. I offer my thoughts on why it misses the point.
The problem with CSS pre-processing frameworks is that they don’t really fit within the average web designers’ work flow. So I built an extension to LESS for creating cached stylesheets your PHP projects can use.
Are you a web designer or are you a web developer? Let me guess, you are a bit of both. Does that mean you are “doing it wrong”?
If you’re like me then your life revolves around email. Unfortunately the grip that email now has on all our lives creates as many problems as it solves. Learn how I control my Inbox.
“@RyanRoberts I think I'd need to sit 3M away to feel comfortable. My eyes are bad enough, their deterioration does not need any encouraging!”
Posted about 2 hours ago.
This site is proudly powered by WordPress. If you like what you see, why not subscribe?
Copyright © 2008-2010 Aaron Russell. All rights reserved.