Need Advice? CALL: +61 417949565

Riksi - web design and development

  • Home
  • ABOUT US
  • OUR WORK
  • BLOG
  • CONTACT US
  • Home
  • BLOG
  • Web developing
  • CSS
  • Compile SASS with PHP

Compile SASS with PHP

Compile SASS with PHP

cssphp is a cool tools to compile SCSS file in PHP.

SCSS is a CSS preprocessor language that adds many features like variables, mixins, imports, nesting, color manipulation, functions, and control directives.

scssphp is ready for inclusion in any project. It includes a command-line tool for running the compiler from a terminal/shell or script.

How to use it:

use the composer.json and add the following code

1
2
3
4
5
6
7
8
9
 
 
{
    "require": {
        "scssphp/scssphp": "1.2"
    }
}
 
 

then in the php file, add the following code to compile the sass fie

dd

1
2
3
4
5
6
7
8
9
10
11
12
13
 
 
require_once "scssphp/scss.inc.php";
use ScssPhp\ScssPhp\Compiler;
 
$scss = new Compiler();
 
echo $scss->compile('
  $color: #abc;
  div { color: lighten($color, 20%); }
');
 
 

For a variable, you can add the setVariables function:

1
2
3
4
5
6
7
8
9
10
11
12
 
 
use ScssPhp\ScssPhp\Compiler;
 
$scss = new Compiler();
$scss->setVariables(array(
    'red' => 'false',
));
$sassfile="/path/to/scss/file";
echo $scss->compile($sassfile);
 
 
Tagged under: PHP Trick, scss
Nick
Tuesday, 12 March 2019 / Published in CSS, PHP

What you can read next

Show WordPress Page Content in Another Post Template
Using WordPress Functionality outside wp
Deployer – PHP deployment tool – Get started

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Archive

  • General
    • Smart Home
  • Web developing
    • command line
    • CSS
    • General
    • git
    • Javascript
    • Laravel
    • Magento
    • MySQL
    • PHP
    • Security
    • Shopify
    • Wordpress

Recent Posts

  • Install HomeAssistant on Raspberry pi

  • Shopify ERR_INVALID_ARG_TYPE Error

Riksi

Riksi is a creative, professional & cutting-edge custom web design and development company.

HERE TO HELP

  • BLOG
  • Contact Us
  • Our Work
  • About Us

New on Blog

  • Install HomeAssistant on Raspberry pi

    To install it, We need to connect the SD card t...
  • Shopify ERR_INVALID_ARG_TYPE Error

    fix the Internal Server Error occurred while in...

GET IN TOUCH

T: (+61) 417 949 565
Email: [email protected]

Contact Us
Fill out the form and our team will be in touch with you promptly. Thank you for your interest!

AU & NZ
T: (+613) 9014 9495
T: (+61) 417 949 565
Email: [email protected]


US & Canada
Email: [email protected]

NAME

EMAIL

PROJECT TYPE
PROJECT BUDGET

MESSAGE

Could not authenticate you.

Whats on Instagram

Loading...

Tags

.htaccess calculation cherry pick composer content css deployer documentation error flex general knowledge get started git git stash hack javascript log mysql package password php PHP Trick replace scss shopify sidebar ssh symlink sync trick ubuntu windows 10 wordpress trick wp
  • GET SOCIAL
Riksi - web design and development

© 2020 All rights reserved. Riksi.com.

TOP