grinder_php_minify 0.2.0 copy "grinder_php_minify: ^0.2.0" to clipboard
grinder_php_minify: ^0.2.0 copied to clipboard

discontinued
outdated

Grinder plug-in minifying PHP source code by removing comments and whitespace.

Grinder-PHP-Minify #

Runtime Release License Coverage Build

Grinder plug-in minifying PHP source code by removing comments and whitespace.

Getting started #

If you haven't used Grinder before, be sure to check out the related documentation, as it explains how to create a grind.dart file and to define project tasks. Once you're familiar with that process, you may install this plug-in.

Installing via Pub #

1. Depend on it #

Add this to your package's pubspec.yaml file:

devDpendencies:
  grinder_php_minify: *

2. Install it #

Install this package and its dependencies from a command prompt:

$ pub get

Once the plug-in has been installed, it may be enabled inside your grind.dart file:

import 'package:grinder_php_minify/grinder_php_minify.dart' as php_minify;

Usage #

The plug-in takes a list of PHP scripts as input, and removes the comments and whitespace in these files by applying the php_strip_whitespace() function on their contents.

Two functions are dedicated to this feature:

  • compress(): minifies the PHP files of a given source directory and saves the resulting output to a destination directory.
  • compressFile(): minifies a single PHP source file and saves the resulting output to a given destination file.

Their usage is the same, only their options differ:

import 'dart:async';
import 'package:grinder/grinder.dart';
import 'package:grinder_php_minify/grinder_php_minify.dart' as php_minify;

@Task('Compress the PHP scripts from a given directory')
Future phpDirectory() => php_minify.compress('path/to/src', 'path/to/out');

@Task('Compress a given PHP script')
Future phpFile() => php_minify.compressFile('path/to/src/file.php', 'path/to/out/file.php');

Common options #

These options are shared by the two functions: compress() and compressFile().

binary #

The plug-in relies on the availability of the PHP executable on the target system. By default, the plug-in will use the php binary found on the system path.

If the plug-in 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:

php_minify.compress('path/to/src', 'path/to/out', binary: r'C:\Program Files\PHP\php.exe');
php_minify.compressFile('path/to/src/file.php', 'path/to/out/file.php', binary: '/usr/local/bin/php7');

mode #

The plug-in 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 very reliable. It spawns a PHP web server that processes the input files, but on some systems this fails. This mode requires a PHP runtime version 7.0 or later.
php_minify.compress('path/to/src', 'path/to/out', mode: 'fast');
php_minify.compressFile('path/to/src/file.php', 'path/to/out/file.php', mode: 'fast');

silent #

By default, the plug-in prints to the standard output the paths of the minified scripts. You can disable this output by setting the silent option to true.

php_minify.compress('path/to/src', 'path/to/out', silent: true);
php_minify.compressFile('path/to/src/file.php', 'path/to/out/file.php', silent: true);

Directory options #

These options are specific to the compress() function.

pattern #

When processing a directory, a filter is applied on the names of the processed files to determine whether they are PHP scripts. A filename pattern is used to match the eligible PHP scripts.

By default, it's set to "*.php". You can change this pattern to select a different set of PHP scripts:

php_minify.compress('path/to/src', 'path/to/out', pattern: '*.inc.php7');

recurse #

By default, a source directory is scanned recursively. You can force the minifier to only process the files located at the root of the source directory by setting the recurse option to false:

php_minify.compress('path/to/src', 'path/to/out', recurse: false);

See also #

License #

Grinder-PHP-Minify is distributed under the Apache License, version 2.0.

0
likes
0
pub points
0%
popularity

Publisher

verified publisherbelin.io

Grinder plug-in minifying PHP source code by removing comments and whitespace.

Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (LICENSE)

Dependencies

grinder, http, path, which

More

Packages that depend on grinder_php_minify