EzDevInfo.com

css-crush

CSS preprocessor. Written in PHP CSS-Crush ~ CSS pre-processor a standards inspired css pre-processor. written in php.

How to Access A To String Function with PHP?

I am using the PHP CSS preprocessor CssCrush for the first time and I am needing to implement the csscrush_string() function into my custom assets manager. Previously I was using CssMin but now I need use of the preprocessor.

The following snippet below obviously has a syntax error at $data = csscrush_string( string $string [, array $options ] ); and I do not know how to correct it - I'm a PHP newbie.

UPDATE: I have also tried: $data = Crush::csscrush_string(); but I get PHP Fatal error: Class 'Crush' not found... even-though Crush is a class.

Using CssCrush (replacing CssMin):

<?php

private function process_resource($file, $type)
{
     //...Files are combined and dumped into $data up here
    // before running the preprocessor and minifier...

    $data = str_replace($keys, $vals, $data);
    $css_lib = VENDOR_DIR . "css-crush/css-crush/CssCrush.php";
    if ($this->settings[$type]["minify"])
    {
        require $css_lib;
        $data = csscrush_string( string $string [, array $options ] );
        $data = trim($data);
    }
}

Using CssMin (works):

<?php

$data = str_replace($keys, $vals, $data);
css_lib = VENDOR_DIR . "natxet/CssMin/src/CssMin.php";
if ($this->settings[$type]["minify"])
{
    require $css_lib;
    $data = CssMin::minify($data);
    $data = trim($data);
}

Any help (code snippet) will be greatly appreciated.


Source: (StackOverflow)