PHP code example of kylekatarnls / stylus

1. Go to this page and download the library: Download kylekatarnls/stylus library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kylekatarnls / stylus example snippets




$stylus = new Stylus();
$stylus->setReadDir('read');
$stylus->setWriteDir('write');
$stylus->setImportDir('import'); //if you import a file without setting this, it will import from the read directory
$stylus->parseFiles();

// From string to string
$css = $stylus->fromString("body\n  color black")->toString();

// From string to file
$stylus->fromString("body\n color black")->toFile("out.css");

// From file to string
$css = $stylus->fromFile("in.styl")->toString();

// From file to file
$stylus->fromFile("in.styl")->toFile("out.css");

$stylus->assign('px_size', '30px');
$stylus->parseFiles();