One simple PHP file that "watches" your SASS file folder and compiles all .scss automatically every X seconds. Sounds weird, but works perfectly. Automatic SASS compiling with 100% PHP. No Ruby used.
This was meant as an experiment and resulted in Laravel SASS, a better compiler for SASS in pure PHP. There are also better scripts for doing this job, like all the JavaScript build tools. Please keep this in mind :) !
The php-sass-watcher is not a standalone compiler, it's just a little method that uses the excellent scssphp compiler written by Leaf Corcoran and adds automatic interval-compiling to it.
The php-sass-watcher is one simple php file that runs an unlimited time (!) and compiles all .scss files in your scss folder to .css files in your css folder automatically in a configurable interval (which is 1 second by default). That's it. No configuration (outside of the file itself) needs to be done, you can install it within 60 seconds. It does not mess up your development environment, it's just a tiny file.
To keep things as minimal as possible, this tool compiles every X seconds, regardless of changes within the files. This seems weird, but makes sense as checking for changes in the files is more CPU-extensive than simply re-compiling them. SassWatcher uses scssphp, the best SASS compiler in PHP available.
The currently supported version of SCSS syntax is 3.2.12, which is the latest one. To avoid confusion: SASS is the name of the language itself, and also the "name" of the "first" version of the syntax (which was quite different than CSS). Then SASS's syntax was changed to "SCSS", which is more like CSS, but with awesome additional possibilities and features. The compiler uses the SCSS syntax, which is recommended and mostly used. The old SASS syntax is not supported.
Please note: Some IDEs / code editors don't show new/updated files instantly. Refresh/reload the files/folders to see the changes.
$sass_watcher = new SassWatcher();
$sass_watcher->watch("path/to/scss/", "path/to/css/", 1, "vendor/leafo/scssphp/scss.inc.php");
"leafo/scssphp": "0.0.9"
Currently your mixin files need to be in exactly the same folder like your other .scss, then the @import will work perfectly. Custom mixing folders are on my todo-list.
If you like, check my other projects:
A super-reduced and naked bare-bone application, just a little application skeleton.
A collection of 4 login scripts for PHP, from a super-simple one-file script with a SQLite one-file to a quite professional MVC frameworks solution (that has been used in large projects). All scripts use the most advanced hashing algorithms possible in PHP, exactly like the PHP core developers want you to use them.
https://github.com/panique/huge (full framework)
https://github.com/panique/php-login-minimal (minimal)
https://github.com/panique/php-login-advanced (advanced)
https://github.com/panique/php-login-one-file (one-file)
This project is licensed under the MIT License. This means you can use and modify it for free in private or commercial projects.
Feel free to contribute (it's okay to push to master branch as this project is really small).
If you think this script is useful and saves you a lot of work, then think about supporting the project by renting a server at HOST1PLUS.