PHP Class Leafo\ScssPhp\Server

Author: Leaf Corcoran ([email protected])
Mostrar archivo Open project: leafo/scssphp Class Usage Examples

Public Methods

Method Description
__construct ( string $dir, string $cacheDir = null, Compiler | null $scss = null ) Constructor
checkedCachedCompile ( string $in, string $out, boolean $force = false ) : string Based on explicit input/output files does a full change check on cache before compiling.
checkedCompile ( string $in, string $out ) : boolean Check if file need compiling
compileFile ( string $in, string $out = null ) : string | boolean Compile .scss file
serve ( string $salt = '' ) Compile requested scss and serve css. Outputs HTTP response.
serveFrom ( string $path ) Helper method to serve compiled scss
showErrorsAsCSS ( boolean $show = true ) Render errors as a pseudo-element within valid CSS, displaying the errors on any page that includes this CSS.

Protected Methods

Method Description
cacheName ( $fname ) : string Get path to cached .css file
compile ( string $in, string $out ) : array Compile .scss file
createErrorCSS ( Exception $error ) : string Format error as a pseudo-element in CSS
findInput ( ) : string Get path to requested .scss file
getIfModifiedSinceHeader ( ) : string | null Get If-Modified-Since header from client request
getIfNoneMatchHeader ( ) : string | null Get If-None-Match header from client request
inputName ( ) : string | null Get name of requested .scss file
join ( string $left, string $right ) : string Join path components
metadataName ( $out ) : string Get path to meta data
needsCompile ( string $out, string &$etag ) : boolean Determine whether .scss file needs to be re-compiled.

Method Details

__construct() public method

Constructor
public __construct ( string $dir, string $cacheDir = null, Compiler | null $scss = null )
$dir string Root directory to .scss files
$cacheDir string Cache directory
$scss Compiler | null SCSS compiler instance

cacheName() protected method

Get path to cached .css file
protected cacheName ( $fname ) : string
return string

checkedCachedCompile() public method

Based on explicit input/output files does a full change check on cache before compiling.
public checkedCachedCompile ( string $in, string $out, boolean $force = false ) : string
$in string
$out string
$force boolean
return string Compiled CSS results

checkedCompile() public method

Check if file need compiling
public checkedCompile ( string $in, string $out ) : boolean
$in string Input file (.scss)
$out string Output file (.css)
return boolean

compile() protected method

Compile .scss file
protected compile ( string $in, string $out ) : array
$in string Input path (.scss)
$out string Output path (.css)
return array

compileFile() public method

Compile .scss file
public compileFile ( string $in, string $out = null ) : string | boolean
$in string Input file (.scss)
$out string Output file (.css) optional
return string | boolean

createErrorCSS() protected method

Format error as a pseudo-element in CSS
protected createErrorCSS ( Exception $error ) : string
$error Exception
return string

findInput() protected method

Get path to requested .scss file
protected findInput ( ) : string
return string

getIfModifiedSinceHeader() protected method

Get If-Modified-Since header from client request
protected getIfModifiedSinceHeader ( ) : string | null
return string | null

getIfNoneMatchHeader() protected method

Get If-None-Match header from client request
protected getIfNoneMatchHeader ( ) : string | null
return string | null

inputName() protected method

Get name of requested .scss file
protected inputName ( ) : string | null
return string | null

join() protected method

Join path components
protected join ( string $left, string $right ) : string
$left string Path component, left of the directory separator
$right string Path component, right of the directory separator
return string

metadataName() protected method

Get path to meta data
protected metadataName ( $out ) : string
return string

needsCompile() protected method

Determine whether .scss file needs to be re-compiled.
protected needsCompile ( string $out, string &$etag ) : boolean
$out string Output path
$etag string ETag
return boolean True if compile required.

serve() public method

Compile requested scss and serve css. Outputs HTTP response.
public serve ( string $salt = '' )
$salt string Prefix a string to the filename for creating the cache name hash

serveFrom() public static method

Helper method to serve compiled scss
public static serveFrom ( string $path )
$path string Root path

showErrorsAsCSS() public method

Render errors as a pseudo-element within valid CSS, displaying the errors on any page that includes this CSS.
public showErrorsAsCSS ( boolean $show = true )
$show boolean