Skip to content

Commit

Permalink
Update the documentation [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
cedx committed Jan 26, 2024
1 parent da820e1 commit 3f92d02
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 90 deletions.
1 change: 0 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<script defer src="https://cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/docsify/lib/plugins/search.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/docsify-pagination/dist/docsify-pagination.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/docsify-tabs/dist/docsify-tabs.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/prismjs/components/prism-bash.min.js"></script>

<script>
Expand Down
14 changes: 1 addition & 13 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ You can verify if you're already good to go with the following command:

```shell
node --version
# v20.5.0
# v21.6.1
```

## Installing with npm package manager
Expand All @@ -23,18 +23,6 @@ npm install @cedx/php-minifier
### 2. Import it
Now in your [JavaScript](https://developer.mozilla.org/docs/Web/JavaScript) code, you can use:

<!-- tabs:start -->

#### **CommonJS module**

```js
const phpMinifier = require("@cedx/php-minifier");
```

#### **ECMAScript module**

```js
import phpMinifier from "@cedx/php-minifier";
```

<!-- tabs:end -->
76 changes: 0 additions & 76 deletions docs/usage/gulp.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,6 @@ Once you're familiar with that process, you may install this plugin.
## Programming interface
The plugin takes a list of [PHP](https://www.php.net) scripts as input, and removes the comments and whitespace in these files by applying the [`php_strip_whitespace()`](https://www.php.net/manual/en/function.php-strip-whitespace.php) function on their contents:

<!-- tabs:start -->

#### **CommonJS module**

```js
const {dest, src} = require("gulp");
const phpMinifier = require("@cedx/php-minifier");

exports.compressPhp = function compressPhp() {
return src("path/to/**/*.php", {read: false})
.pipe(phpMinifier())
.pipe(dest("path/to/out"));
}
```

#### **ECMAScript module**

```js
import gulp from "gulp";
import phpMinifier from "@cedx/php-minifier";
Expand All @@ -33,8 +16,6 @@ export function compressPhp() {
}
```

<!-- tabs:end -->

> **Caution:** the plugin only needs the file paths, so you should specify the `read` option to `false` when providing the file list, and you should not have any other plugin before it.
## Options
Expand All @@ -43,23 +24,6 @@ export function compressPhp() {
The plugin relies on the availability of the [PHP](https://www.php.net) executable on the target system. By default, the plugin will use the `php` binary found on the system path.
If the plugin cannot find the default `php` binary, or if you want to use a different one, you can provide the path to the `php` executable by using the `binary` option:

<!-- tabs:start -->

#### **CommonJS module**

```js
const {dest, src} = require("gulp");
const phpMinifier = require("@cedx/php-minifier");

exports.compressPhp = function compressPhp() {
return src("path/to/**/*.php", {read: false})
.pipe(phpMinifier({binary: "C:\\Program Files\\PHP\\php.exe"}))
.pipe(dest("path/to/out"));
}
```

#### **ECMAScript module**

```js
import gulp from "gulp";
import phpMinifier from "@cedx/php-minifier";
Expand All @@ -71,31 +35,12 @@ export function compressPhp() {
}
```

<!-- tabs:end -->

### **mode**: TransformMode = `"safe"`
The plugin can work in two manners, which can be selected using the `mode` option:

- the `safe` mode: as its name implies, this mode is very reliable. But it is also very slow as it spawns a new PHP process for every file to be processed. This is the default mode.
- the `fast` mode: as its name implies, this mode is very fast, but it is not always reliable. It spawns a PHP web server that processes the input files, but on some systems this fails.

<!-- tabs:start -->

#### **CommonJS module**

```js
const {dest, src} = require("gulp");
const phpMinifier = require("@cedx/php-minifier");

exports.compressPhp = function compressPhp() {
return src("path/to/**/*.php", {read: false})
.pipe(phpMinifier({mode: "fast"}))
.pipe(dest("path/to/out"));
}
```

#### **ECMAScript module**

```js
import gulp from "gulp";
import phpMinifier from "@cedx/php-minifier";
Expand All @@ -107,31 +52,12 @@ export function compressPhp() {
}
```

<!-- tabs:end -->


> The plugin defaults to the `safe` mode, but you should really give a try to the `fast` one. The difference is very noticeable.
### **silent**: boolean = `false`
By default, the plugin prints to the standard output the paths of the minified scripts. You can disable this output by setting the `silent` option to `true`.

<!-- tabs:start -->

#### **CommonJS module**

```js
const {dest, src} = require("gulp");
const phpMinifier = require("@cedx/php-minifier");

exports.compressPhp = function compressPhp() {
return src("path/to/**/*.php", {read: false})
.pipe(phpMinifier({silent: true}))
.pipe(dest("path/to/out"));
}
```

#### **ECMAScript module**

```js
import gulp from "gulp";
import phpMinifier from "@cedx/php-minifier";
Expand All @@ -142,5 +68,3 @@ export function compressPhp() {
.pipe(gulp.dest("path/to/out"));
}
```

<!-- tabs:end -->

0 comments on commit 3f92d02

Please sign in to comment.