Skip to content
forked from rukzuk/sassphp

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

License

Notifications You must be signed in to change notification settings

mansurs/sassphp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sassphp

The sass extension for PHP gives you an object-oriented system of parsing Sass from within your PHP applications. Under the hood it uses libsass to provide super speedy and compatible Sass parsing.

What's 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). The extension and continuing evolution of the language has all been the result of years of work by Nathan Weizenbaum (@nex3) and Chris Eppstein (@chriseppstein).

For more information about Sass itself, please visit http://sass-lang.com

Installation

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

$ git clone git://github.com/rukzuk/sassphp

Remember to grab your submodules:

$ git submodule init
$ git submodule update

And the same for the sub submodules!

$ cd lib/libsass
$ git submodule init
$ git submodule update

...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

Usage

This extension has a very simple API:

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

You can compile a file with compile_file():

$sass = new Sass();
$css = $sass->compile_file($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 compress style before compiling it (Default is STYLE_NESTED):

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

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;
}

Changelog

** Version 0.3.0**

  • Allow setting compress style

** Version 0.2.0**

  • Changed methods to be non-static
  • Allow setting include-path and image-path

Version 0.1.0 - IN DEVELOPMENT

  • Initial release

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • CSS 99.3%
  • Other 0.7%