99
1010### Including
1111
12- The entire project comes in a single file. Just include it somewhere to start
13- using it:
12+ The project can be loaded through a ` composer ` generated auto-loader.
13+
14+ Alternatively, the entire project can be loaded through a utility file.
15+ Just include it somewhere to start using it:
1416
1517 ```php
1618 <?php
@@ -20,13 +22,16 @@ using it:
2022### Compiling
2123
2224In order to manually compile code from PHP you must create an instance of the
23- ` scssc ` class. The typical flow is to create the instance, set any compile time
25+ ` Compiler ` class. The typical flow is to create the instance, set any compile time
2426options, then run the compiler with the ` compile ` method.
2527
2628 ```php
2729 <?php
2830 require "scssphp/scss.inc.php";
29- $scss = new scssc();
31+
32+ use Leafo\ScssPhp\Compiler;
33+
34+ $scss = new Compiler();
3035
3136 echo $scss->compile('
3237 $color: #abc;
@@ -59,7 +64,10 @@ The default import path is `array("")`, which means the current directory.
5964 ```php
6065 <?php
6166 require "scssphp/scss.inc.php";
62- $scss = new scssc();
67+
68+ use Leafo\ScssPhp\Compiler;
69+
70+ $scss = new Compiler();
6371 $scss->setImportPaths("assets/stylesheets/");
6472
6573 // will search for `assets/stylesheets/mixins.scss'
@@ -73,7 +81,10 @@ files that SCSS would otherwise not process (such as vanilla CSS imports).
7381 ```php
7482 <?php
7583 require "scssphp/scss.inc.php";
76- $scss = new scssc();
84+
85+ use Leafo\ScssPhp\Compiler;
86+
87+ $scss = new Compiler();
7788 $scss->addImportPath(function($path) {
7889 if (!file_exists('stylesheets/'.$path)) return null;
7990 return 'stylesheets/'.$path;
@@ -90,15 +101,15 @@ default formatter.
90101
91102Three formatters are included:
92103
93- * ` scss_formatter `
94- * ` scss_formatter_nested ` * (default)*
95- * ` scss_formatter_compressed `
104+ * ` Leafo\ScssPhp\Formatter\Expanded `
105+ * ` Leafo\ScssPhp\Formatter\Nested ` * (default)*
106+ * ` Leafo\ScssPhp\Formatter\Compressed `
96107
97108We can change the formatting using the ` setFormatter ` method.
98109
99110* <p >`setFormatter($formatterName)` sets the current formatter to `$formatterName`,
100111 the name of a class as a string that implements the formatting interface. See
101- the source for ` scss_formatter ` for an example.
112+ the source for ` Leafo\ScssPhp\Formatter\Expanded ` for an example.
102113 </p >
103114
104115Given the following SCSS:
@@ -123,7 +134,7 @@ Given the following SCSS:
123134
124135The formatters will output,
125136
126- ` scss_formatter ` :
137+ ` Leafo\ScssPhp\Formatter\Expanded ` :
127138
128139 ```css
129140 .navigation ul {
@@ -138,7 +149,7 @@ The formatters will output,
138149 }
139150 ```
140151
141- ` scss_formatter_nested ` :
152+ ` Leafo\ScssPhp\Formatter\Nested ` :
142153
143154 ```css
144155 .navigation ul {
@@ -151,7 +162,7 @@ The formatters will output,
151162 color: silver; }
152163 ```
153164
154- ` scss_formatter_compressed ` :
165+ ` Leafo\ScssPhp\Formatter\Compressed ` :
155166
156167 ```css
157168 .navigation ul{line-height:20px;color:blue;}.navigation ul a{color:red;}.footer .copyright{color:silver;}
@@ -198,7 +209,9 @@ together. PHP's anonymous function syntax is used to define the function.
198209
199210 ```php
200211 <?php
201- $scss = new scssc();
212+ use Leafo\ScssPhp\Compiler;
213+
214+ $scss = new Compiler();
202215
203216 $scss->registerFunction("add-two", function($args) {
204217 list($a, $b) = $args;
@@ -223,7 +236,7 @@ files if they've been modified (or one of the imports has been modified).
223236
224237### Using ` serveFrom `
225238
226- ` scss_server ::serveFrom` is a simple to use function that should handle most cases.
239+ ` Server ::serveFrom` is a simple to use function that should handle most cases.
227240
228241For example, create a file ` style.php ` :
229242
@@ -232,13 +245,16 @@ For example, create a file `style.php`:
232245 $directory = "stylesheets";
233246
234247 require "scssphp/scss.inc.php";
235- scss_server::serveFrom($directory);
248+
249+ use Leafo\ScssPhp\Server;
250+
251+ Server::serveFrom($directory);
236252 ```
237253
238254Going to the URL ` example.com/style.php/style.scss ` will attempt to compile
239255` style.scss ` from the ` stylesheets ` directory, and serve it as CSS.
240256
241- * <p >`scss_server ::serveFrom($directory)` will serve SCSS files out of
257+ * <p >`Server ::serveFrom($directory)` will serve SCSS files out of
242258 ` $directory ` . It will attempt to get the path to the file out of
243259 ` $_SERVER["PATH_INFO"] ` . (It also looks at the GET parameter ` p ` )
244260 </p >
@@ -262,14 +278,14 @@ directory. It writes its cache in a special directory called `scss_cache`.
262278Also, because SCSS server writes headers, make sure no output is written before
263279it runs.
264280
265- ### Using ` scss_server `
281+ ### Using ` Leafo\ScssPhp\Server `
266282
267- Creating an instance of ` scss_server ` is just another way of accomplishing what
268- ` serveFrom ` does. It let's us customize the cache directory and the instance
269- of the ` scssc ` that is used to compile
283+ Creating an instance of ` Server ` is just another way of accomplishing what
284+ ` serveFrom ` does. It lets us customize the cache directory and the instance
285+ of the ` Compiler ` that is used to compile
270286
271287
272- * <p >`new scss_server ($sourceDir, $cacheDir, $scss)` creates a new server that
288+ * <p >`new Server ($sourceDir, $cacheDir, $scss)` creates a new server that
273289 serves files from ` $sourceDir ` . The cache dir is where the cached compiled
274290 files are placed. When ` null ` , ` $sourceDir . "/scss_cache" ` is used. ` $scss `
275291 is the instance of ` scss ` that is used to compile.
@@ -283,10 +299,13 @@ Here's an example of creating a SCSS server that outputs compressed CSS:
283299 <?php
284300 require "scssphp/scss.inc.php";
285301
286- $scss = new scssc();
302+ use Leafo\ScssPhp\Compiler;
303+ use Leafo\ScssPhp\Server;
304+
305+ $scss = new Compiler();
287306 $scss->setFormatter("scss_formatter_compressed");
288307
289- $server = new scss_server ("stylesheets", null, $scss);
308+ $server = new Server ("stylesheets", null, $scss);
290309 $server->serve();
291310 ```
292311
@@ -301,6 +320,6 @@ If passed the flag `-v`, input is ignored and the current version if returned.
301320The flag ` -f ` can be used to set the [ formatter] ( #Output_formatting ) :
302321
303322 ```bash
304- $ . /pscss -f scss_formatter_compressed < styles.scss
323+ $ bin /pscss -f scss_formatter_compressed < styles.scss
305324 ```
306325
0 commit comments