Is there a parser/library for "css stylus" available for php?
If not please suggest something similar, if not better. Possibly a light weight library that makes your life coding css, easier in php.
Stylus syntax strips away all colons, semicolons, brackets and most parentheses from regular CSS script. The stark simplicity and elegance of it reminds me of Lisp. What's more amazing is that Stylus will also accept regular CSS syntax in the same file, reducing possible friction between multiple contributers.
I too was looking for a Stylus parser for PHP. After finding none, I created a basic one and put it up on GitHub for others to use / improve upon.
Current Features 3/20/2013:
Bump. It seems that there still isn't an easy to use method of incorporating stylus into php. Here's my workaround (linux only, local development only). It is inspired by my other recent question about FAM.
install incron and stylus, under ubuntu this would be
sudo apt-get install incron
sudo npm install stylus -g
access incron watch table
incrontab -e
and add the following with suitable modifications:
/var/www/css/my.styl IN_MODIFY /usr/local/bin/stylus /var/www/css/my.styl
which basically means recompile my.styl into my.css on file change.
add resulting css to html header
<link href="path/tom/my.css" rel="stylesheet" type="text/css" />
Whenever you save the .styl
file, your .css
will be recompiled in the background. Skip the styus file in deployment, use the recompiled one.
No. But there are plenty alternatives that you could look in to, like LESS, Sass, HSS. Maybe there's a PHP parser for one of these.
Why not just use the original Node.js implementation?
exec
will work just fine, but you should only use it in a development environment.
<?php exec('/path/to/stylus stylesheet.styl'); ?>
In production you should precompile your Stylus for sake of both performance and security.
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