scssphp is a compiler for SCSS written in PHP.

SCSS is a CSS preprocessor that adds many features like variables, mixins, imports, color manipulation, functions, and tons of other powerful features.

The entire compiler comes in a single class file ready for including in any kind of project in addition to a command line tool for running the compiler from the terminal.

scssphp implements SCSS (3.2.12). It does not implement the SASS syntax, only the SCSS syntax.

Follow the author on twitter: @moonscript.


You can always download the latest version here:

You can also find the latest source online:

If you use Packagist for installing packages, then you can update your composer.json like so:

  "require": {
    "leafo/scssphp": "0.0.12"

Language Reference

For a complete guide to the syntax of SCSS, consult the official documentation.

PHP Reference

Complete documentation for scssphp is located at


If you just want to start serving compiled scss files as quick as possible then start here.

scssphp comes with a easy to use class that automatically compiles modified scss files and serves them from a directory you specify.

Create a file, like style.php:

$directory = "stylesheets";

require "scssphp/";

Create the directory set in the script alongside the script, then add your scss files to it.

If we've got a file in there called style.scss, then we just need to hit the url: to get the compiled css.

If there is an error compiling, the url will result in a 500 error with the error message. If the file can’t be found, then a friendly 404 is returned.

scssphp will automatically create a scss_cache directory inside the stylesheets directory where it will cache the compiled output. This way it can quickly serve the files if no modifications have been made. Your PHP script must have permission to write in scss_cache.

Compiler Interface

If you're interested in directly using the compiler, then all you need to do is require and invoke the scss class:

require "scssphp/";
$scss = new scssc();

echo $scss->compile('
  $color: #abc;
  div { color: lighten($color, 20%); }

The compile method takes SCSS as a string, and returns the CSS. If there is an error when compiling then an exception is thrown with an appropriate message.

For a more detailed guide consult


Find any issues? I'd love to fix them for you, post about them on the issues tracker.



Fork me on GitHub