Giter VIP home page Giter VIP logo

gulp-php-minify's Introduction

Gulp-PHP-Minify

Release License Dependencies Coverage Build

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

Getting started

If you haven't used Gulp.js before, be sure to check out the related documentation, as it explains how to create a gulpfile.js as well as install and use plug-ins. Once you're familiar with that process, you may install this plug-in with this command:

$ npm install --save-dev @cedx/gulp-php-minify

Once the plug-in has been installed, it may be enabled inside your gulpfile.js.

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:

const gulp = require('gulp');
const {phpMinify} = require('@cedx/gulp-php-minify');

gulp.task('minify:php', () => gulp.src('path/to/lib/**/*.php', {read: false})
  .pipe(phpMinify())
  .pipe(gulp.dest('path/to/out'))
);

The plug-in 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 plug-in before it.

Options

binary

The plug-in relies on the availability of the PHP executable on the target system: it requires a version 5.5 or later. 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:

return gulp.src('path/to/lib/**/*.php', {read: false})
  .pipe(phpMinify({binary: 'C:\\Program Files\\PHP\\php.exe'}))
  .pipe(gulp.dest('path/to/out'));

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.

return gulp.src('path/to/lib/**/*.php', {read: false})
  .pipe(phpMinify({silent: true}))
  .pipe(gulp.dest('path/to/out'));

See also

License

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

gulp-php-minify's People

Contributors

cedx avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.