PHPackages                             abm/sassphp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. abm/sassphp

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

abm/sassphp
===========

PHP bindings to libsass - fast, native Sass parsing in PHP!

0.7(6y ago)559.2k13[2 issues](https://github.com/absalomedia/sassphp/issues)MITCPHP &gt;=5.4.2CI failing

Since Feb 14Pushed 2y ago7 watchersCompare

[ Source](https://github.com/absalomedia/sassphp)[ Packagist](https://packagist.org/packages/abm/sassphp)[ Docs](https://github.com/absalomedia/sassphp)[ RSS](/packages/abm-sassphp/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (5)Used By (0)

sassphp
=======

[](#sassphp)

The `sass` extension for PHP gives you an object-oriented system of parsing [Sass](http://sass-lang.com/) from within your PHP applications. Under the hood it uses [libsass](https://github.com/hcatlin/libsass) to provide super speedy and compatible Sass parsing.

[![Libsass 3.6.3](https://camo.githubusercontent.com/5c8ee2bdf439def17a07530976c960c5381d853bb8711e0ec6f7d00fca84d71d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6962736173732d332e362e332d79656c6c6f772e737667)](https://camo.githubusercontent.com/5c8ee2bdf439def17a07530976c960c5381d853bb8711e0ec6f7d00fca84d71d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6962736173732d332e362e332d79656c6c6f772e737667) [![Build Status](https://camo.githubusercontent.com/7eb3c79b1a3beb710810fcfe0434c740bebb95f73c9ea9bf533ef23e6926019d/68747470733a2f2f7472617669732d63692e6f72672f616273616c6f6d656469612f736173737068702e737667)](https://travis-ci.org/absalomedia/sassphp) [![codecov](https://camo.githubusercontent.com/e87d0e25164585fd73d6a2fa9a9e0ebd63711b811ec8ea9dd86a91d69b4517a4/68747470733a2f2f636f6465636f762e696f2f67682f616273616c6f6d656469612f736173737068702f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/absalomedia/sassphp) [![Patreon](https://camo.githubusercontent.com/63aad09e2ef8221cd8c840ed8b94ef302decaeb147fa8223dd21403f39194f70/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617472656f6e2d646f6e6174652d677265656e2e737667)](https://www.patreon.com/bePatron?u=14641360)

What's Sass?
------------

[](#whats-sass)

Sass is a CSS pre-processor language to add on exciting, new, awesome features to CSS. Sass was the first language of its kind and by far the most mature and up to date codebase.

Sass was originally created by Hampton Catlin ([@hcatlin](http://twitter.com/hcatlin)). The extension and continuing evolution of the language has all been the result of years of work by Natalie Weizenbaum ([@nex3](http://twitter.com/nex3)) and Chris Eppstein ([@chriseppstein](http://twitter.com/chriseppstein)).

For more information about Sass itself, please visit

Installation
------------

[](#installation)

Currently, the only way to install the extension is manually:

```
$ git clone git://github.com/absalomedia/sassphp

```

Remember to grab your submodules:

```
$ git submodule init
$ git submodule update

```

Also remember that libsass now uses submodules on its own, so update those too.

...and compile it! I've written a little PHP script to do all the stuff you need to do:

```
$ php install.php

```

Run the tests:

```
$ make test

```

Finally, you can install with `make`:

```
$ make install

```

And then add it to your *php.ini*:

```
extension=sass.so

```

Always remember to enable it within PHP as well

```
phpenmod sass

```

Binary installation / deployment
--------------------------------

[](#binary-installation--deployment)

As long as you have the final 'sass.so' extension file, you can deploy SASS PHP across any server. There's a few caveats, of course. The development &amp; production servers have to run the same version of PHP. You then copy the installed 'sass.so' from the /usr/lib/php/ directory shown during 'make install' on your development environment to the same directory on your production boxes.

As usual, make sure you add the extension to your *php.ini* on your production environments:

```
extension=sass.so

```

Always remember to enable it within PHP as well

```
phpenmod sass

```

Usage
-----

[](#usage)

This extension has a very simple API:

```
$sass = new Sass();
$css = $sass->compile($source);

```

You can compile a file with `compileFile()`:

```
$sass = new Sass();
$css = $sass->compileFile($source);

```

You can set the include path for the library to use:

```
$sass = new Sass();
$sass->setIncludePath('/tmp');
$css = $sass->compile($source);

```

You can set the style of your SASS file to suit your needs:

```
$sass = new Sass();
$sass->setStyle(Sass::STYLE_NESTED);

$sass = new Sass();
$sass->setStyle(Sass::STYLE_EXPANDED);

$sass = new Sass();
$sass->setStyle(Sass::STYLE_COMPACT);

$sass = new Sass();
$sass->setStyle(Sass::STYLE_COMPRESSED);

```

As the [Libsass](https://github.com/hcatlin/libsass) library has matured to get closer to 100% SASS coverage, so this extension has also matured:

- SASS file compilation is an array when a source map file is specified.
- The ability to define source comments
- The ability to embed the source map into the CSS output
- The ability to specify .SASS file input instead of .SCSS
- The ability to set a source map path, required when generating a dedicated .map file
- The ability to define a root directory for the source map itself
- SASS importer &amp; functions capabilities
- PHP 7.0 to PHP 7.4 support, with tests for PHP 8

The output of `compileFile()` is an array when creating source map files, allowing both compiled SASS file and .map file to be generated in the same function call.

As there are multiple ways of generating source comments, there are now PHP level settings to control that output.

To generate source comments for a file inline:

```
$sass = new Sass();
$sass->setComments(true);
$css = $sass->compileFile($source);

```

Aliases also exist so you can also use:

```
$css = $sass->compile_file($source);

```

You can tell the compiler to use indented syntax (SASS syntax). By default it expects SCSS syntax:

```
$sass = new Sass();
$sass->setIndent(true); //TRUE -> SASS, FALSE -> SCSS
$css = $sass->compile($source);

```

You can tell the compiler to embed the source map into the actual CSS file as well:

```
$sass = new Sass();
$sass->setEmbed(true);
$css = $sass->compile($source);

```

You can set the source map file for the library to use:

```
$sass = new Sass();
$sass->setMapPath('/random.output.css.map');
$css = $sass->compileFile($source);

```

This needs to be done prior to getting the output of the map file. As it stands, both the output of the SASS file compile &amp; the SASS source map file generation sequence are both strings.

The first array item will always be the compiled SASS file: $css\[0\]

The second array item will always be the source map output: $css\[1\]

You can set the root of the generated source map file like so:

```
$sass = new Sass();
$sass->setMapRoot('/some/dir');
$sass->setMapPath('/random.output.css.map');
$css = $sass->compileFile($source);

```

If there's a problem, the extension will throw a `SassException`:

```
$sass = new Sass();

try
{
    $css = $sass->compile('dayrui3dui36di37');
}
catch (SassException $e)
{
    // $e->getMessage() - ERROR -- , line 1: invalid top-level expression

    $css = FALSE;
}

```

Variant builds
--------------

[](#variant-builds)

These extensions also utilise the [Libsass](https://github.com/hcatlin/libsass) library &amp; remain in varying states of completion:

- Facebook [HHVM](https://github.com/absalomedia/sasshhvm) native (non Zend) extension - with Libsass 3.5.5 - tested up to HHVM 3.11.x
- [Nginx](https://github.com/absalomedia/sass-nginx-module) module - with Libsass 3.5.5

Changelog
---------

[](#changelog)

ReleaseDescription0.7.0Librarian - Functions &amp; importers0.6.2Solskjær - Manchester (Libsass 3.6.3)0.6.1Bond - Monaco (Libsass 3.6.1)0.6.0Symfony - Composer integration0.5.17Engine - Vroom vroom (Libsass 3.5.5)0.5.16Humpback - Maloo (Libsass 3.5.4)0.5.15Fallout - Atom (Libsass 3.5.2)0.5.14Karol - Caroline (Libsass 3.4.8)0.5.13Ray - Manta (Libsass 3.4.5) &amp; PHP stub file0.5.12Cartography - MapRoot functions0.5.11Zoomer (Libsass 3.4.4) stable0.5.10Elwood (Libsass 3.4.3) stable &amp; Travis fix0.5.9Rickshaw (Libsass 3.4.2) stable0.5.8AI - KITT (Libsass 3.4.0) stable0.5.7Hancock - Optimise loops &amp; Travis. Simplify changelog documentation0.5.6Green Giant - PHP5 &amp; PHP7 stable build - All Travis builds passing0.5.5Herbie (Libsass 3.3.6) stable0.5.2Delorean (Libsass 3.3.3) stable &amp; continuing PHP7 rewrite0.5.1Eleanor (Libsass 3.3.2) stable0.5.0Start of PHP 7 compatibility0.4.9Too Fast To Furious (Libsass 3.3.1) stable0.4.8Greased Lightning (Libsass 3.3.0) stable0.4.7SCSS vs SASS detection - indents0.4.6Travis experimental (unreleased)0.4.5Holiday Patch (Libsass 3.2.5) stable0.4.4Refactor correctly for LibSass 3.2.40.4.2CamelCase compile sequence0.4.1Addition of SOURCE\_DEFAULT test &amp; structure. Revise other tests0.4.0Refactor file compliation. Basic tests for source comments. Expand documentation0.3.9Addition of source map url paths to SASS file compilation0.3.5Restructure of compile sequence (file only at this time) to account for source map output0.3.0Addition of source comments - none, inline, file. Set default to none.0.2.0Changed methods to be non-static. Allow setting include-path and image-path0.1.0Initial release

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~116 days

Total

4

Last Release

2300d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f2134a0412e72f5202e95f6a0c1da344e0049b481e0758131c11f1db7f876315?d=identicon)[absalomedia](/maintainers/absalomedia)

---

Top Contributors

[![absalomedia](https://avatars.githubusercontent.com/u/3776787?v=4)](https://github.com/absalomedia "absalomedia (311 commits)")[![jamierumbelow](https://avatars.githubusercontent.com/u/49284?v=4)](https://github.com/jamierumbelow "jamierumbelow (28 commits)")[![pilif](https://avatars.githubusercontent.com/u/4990?v=4)](https://github.com/pilif "pilif (17 commits)")[![chrinor2002](https://avatars.githubusercontent.com/u/5445649?v=4)](https://github.com/chrinor2002 "chrinor2002 (4 commits)")[![harnash](https://avatars.githubusercontent.com/u/783242?v=4)](https://github.com/harnash "harnash (4 commits)")[![clayfreeman](https://avatars.githubusercontent.com/u/182658?v=4)](https://github.com/clayfreeman "clayfreeman (3 commits)")[![dubcanada](https://avatars.githubusercontent.com/u/120325?v=4)](https://github.com/dubcanada "dubcanada (2 commits)")[![cuchac](https://avatars.githubusercontent.com/u/165461?v=4)](https://github.com/cuchac "cuchac (1 commits)")[![RdeWilde](https://avatars.githubusercontent.com/u/184016?v=4)](https://github.com/RdeWilde "RdeWilde (1 commits)")

---

Tags

apachephpsasszendphpsassextensionslibsass

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/abm-sassphp/health.svg)

```
[![Health](https://phpackages.com/badges/abm-sassphp/health.svg)](https://phpackages.com/packages/abm-sassphp)
```

###  Alternatives

[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
