grinder_php_minify 1.0.0 copy "grinder_php_minify: ^1.0.0" to clipboard
grinder_php_minify: ^1.0.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' show phpMinify;

Usage #

The plug-in provides a single function, phpMinify(), that takes a PHP script as input, and removes the comments and whitespace in this file by applying the php_strip_whitespace() function on its contents.

The resulting string is saved to a given output directory:

import 'dart:async';
import 'package:grinder/grinder.dart';
import 'package:grinder_php_minify/grinder_php_minify.dart' show phpMinify;

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

The phpMinify() function can also recursively operate on the contents of a directory containing PHP scripts:

@Task('Compress the PHP scripts from a given directory')
Future compressPhp() => phpMinify('path/to/src', 'path/to/out', pattern: '*.php');

Options #

String binary = "php" #

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:

phpMinify('path/to/src', 'path/to/out', binary: r'C:\Program Files\PHP\php.exe');

String mode = "safe" #

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.
phpMinify('path/to/src', 'path/to/out', mode: 'fast');

String pattern = "*.php" #

When processing a directory, a filter is applied on the names of the processed files to determine whether they are PHP scripts.

By default, the filename pattern "*.php" is used to match the eligible PHP scripts. You can change this pattern to select a different set of files:

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

bool recurse = true #

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:

phpMinify('path/to/src', 'path/to/out', recurse: false);

bool silent = false #

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.

phpMinify('path/to/src', 'path/to/out', silent: true);

See also #

License #

Grinder-PHP-Minify is distributed under the MIT License.

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, where

More

Packages that depend on grinder_php_minify