Server
in package
Server
Tags
Table of Contents
- $cacheDir : string
- $dir : string
- $scss : Compiler
- $showErrorsAsCSS : bool
- __construct() : mixed
- Constructor
- cachedCompile() : array<string|int, mixed>
- Execute scssphp on a .scss file or a scssphp cache structure
- checkedCachedCompile() : string
- Based on explicit input/output files does a full change check on cache before compiling.
- checkedCompile() : bool
- Check if file need compiling
- compileFile() : string|bool
- Compile .scss file
- serve() : mixed
- Compile requested scss and serve css. Outputs HTTP response.
- showErrorsAsCSS() : mixed
- Render errors as a pseudo-element within valid CSS, displaying the errors on any page that includes this CSS.
- cacheName() : string
- Get path to cached .css file
- compile() : array<string|int, mixed>
- Compile .scss file
- createErrorCSS() : 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
- Join path components
- metadataName() : string
- Get path to meta data
- needsCompile() : bool
- Determine whether .scss file needs to be re-compiled.
Properties
$cacheDir
private
string
$cacheDir
$dir
private
string
$dir
$scss
private
Compiler
$scss
$showErrorsAsCSS
private
bool
$showErrorsAsCSS
Methods
__construct()
Constructor
public
__construct(string $dir[, string $cacheDir = null ][, Compiler|null $scss = null ]) : mixed
Parameters
- $dir : string
-
Root directory to .scss files
- $cacheDir : string = null
-
Cache directory
- $scss : Compiler|null = null
-
SCSS compiler instance
Return values
mixed —cachedCompile()
Execute scssphp on a .scss file or a scssphp cache structure
public
cachedCompile(mixed $in[, bool $force = false ]) : array<string|int, mixed>
The scssphp cache structure contains information about a specific scss file having been parsed. It can be used as a hint for future calls to determine whether or not a rebuild is required.
The cache structure contains two important keys that may be used externally:
compiled: The final compiled CSS updated: The time (in seconds) the CSS was last compiled
The cache structure is a plain-ol' PHP associative array and can be serialized and unserialized without a hitch.
Parameters
- $in : mixed
-
Input
- $force : bool = false
-
Force rebuild?
Return values
array<string|int, mixed> —scssphp cache structure
checkedCachedCompile()
Based on explicit input/output files does a full change check on cache before compiling.
public
checkedCachedCompile(string $in, string $out[, bool $force = false ]) : string
Parameters
- $in : string
- $out : string
- $force : bool = false
Tags
Return values
string —Compiled CSS results
checkedCompile()
Check if file need compiling
public
checkedCompile(string $in, string $out) : bool
Parameters
- $in : string
-
Input file (.scss)
- $out : string
-
Output file (.css)
Return values
bool —compileFile()
Compile .scss file
public
compileFile(string $in[, string $out = null ]) : string|bool
Parameters
- $in : string
-
Input file (.scss)
- $out : string = null
-
Output file (.css) optional
Tags
Return values
string|bool —serve()
Compile requested scss and serve css. Outputs HTTP response.
public
serve([string $salt = '' ]) : mixed
Parameters
- $salt : string = ''
-
Prefix a string to the filename for creating the cache name hash
Return values
mixed —showErrorsAsCSS()
Render errors as a pseudo-element within valid CSS, displaying the errors on any page that includes this CSS.
public
showErrorsAsCSS([bool $show = true ]) : mixed
Parameters
- $show : bool = true
Return values
mixed —cacheName()
Get path to cached .css file
protected
cacheName(mixed $fname) : string
Parameters
- $fname : mixed
Return values
string —compile()
Compile .scss file
protected
compile(string $in, string $out) : array<string|int, mixed>
Parameters
- $in : string
-
Input path (.scss)
- $out : string
-
Output path (.css)
Return values
array<string|int, mixed> —createErrorCSS()
Format error as a pseudo-element in CSS
protected
createErrorCSS(Exception $error) : string
Parameters
- $error : Exception
Return values
string —findInput()
Get path to requested .scss file
protected
findInput() : string
Return values
string —getIfModifiedSinceHeader()
Get If-Modified-Since header from client request
protected
getIfModifiedSinceHeader() : string|null
Return values
string|null —getIfNoneMatchHeader()
Get If-None-Match header from client request
protected
getIfNoneMatchHeader() : string|null
Return values
string|null —inputName()
Get name of requested .scss file
protected
inputName() : string|null
Return values
string|null —join()
Join path components
protected
join(string $left, string $right) : string
Parameters
- $left : string
-
Path component, left of the directory separator
- $right : string
-
Path component, right of the directory separator
Return values
string —metadataName()
Get path to meta data
protected
metadataName(mixed $out) : string
Parameters
- $out : mixed
Return values
string —needsCompile()
Determine whether .scss file needs to be re-compiled.
protected
needsCompile(string $out, string &$etag) : bool
Parameters
- $out : string
-
Output path
- $etag : string
-
ETag
Return values
bool —True if compile required.