PHP Class Leafo\ScssPhp\Server

Author: Leaf Corcoran ([email protected])
Afficher le fichier Open project: leafo/scssphp Class Usage Examples

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode 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 méthode

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 méthode

Get path to cached .css file
protected cacheName ( $fname ) : string
Résultat string

checkedCachedCompile() public méthode

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
Résultat string Compiled CSS results

checkedCompile() public méthode

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

compile() protected méthode

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

compileFile() public méthode

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

createErrorCSS() protected méthode

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

findInput() protected méthode

Get path to requested .scss file
protected findInput ( ) : string
Résultat string

getIfModifiedSinceHeader() protected méthode

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

getIfNoneMatchHeader() protected méthode

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

inputName() protected méthode

Get name of requested .scss file
protected inputName ( ) : string | null
Résultat string | null

join() protected méthode

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
Résultat string

metadataName() protected méthode

Get path to meta data
protected metadataName ( $out ) : string
Résultat string

needsCompile() protected méthode

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

serve() public méthode

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 méthode

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

showErrorsAsCSS() public méthode

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