npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gulp-phpipe

v1.1.0

Published

Run files through the PHP processor

Readme

gulp-phpipe

gulp-phpipe simply runs files through the PHP processor. This can be used to generate static HTML from PHP code or to do simple PHP templating. This uses your systems PHP binary and if you don't have one, this will not work. Since this is a gulp plugin and gulp works with transient file streams, the (quite possibly virtual) file contents are piped to the PHP process which has some implications:

  • __FILE__ is set to - in the executed code. This does not hold for files included from the root file; see below
  • dirname(__FILE__) will return . which stems from the file path being -
  • __DIR__ is set to the PHP process working directory which is set to the processed Vinyl file's base path overwritten explicitly; see options

Usage

Basic Example

source.php

<h1>Test</h1>
<div><?php echo "Hello World"; ?></div>

Gulpfile.js

var gulp = require('gulp'),
    rename = require('gulp-rename'),
    phpipe = require('gulp-phpipe');

gulp.task('default', function () {
    gulp.src('*.php')
        .pipe(phpipe())
        .pipe(rename(function (path) {
            path.extname = ".html";
            return path;
        }))
        .pipe(gulp.dest('compiled'));
});

This results in compiled/source.html

<h1>Test</h1>
<div>Hello World</div>

Working With Includes

templates/base.php

<h1>Test</h1>
<?php include(__DIR__ . 'inner.php'); ?>

templates/inner.php

<h2>This is included from <?php echo __FILE__; ?></h2>

Gulpfile.js

var gulp = require('gulp'),
    rename = require('gulp-rename'),
    phpipe = require('gulp-phpipe');

gulp.task('default', function () {
    gulp.src('templates/*.php')
        .pipe(phpipe())
        // If the glob used to gather the PHP files were "**/*.php", then the include would not
        // work unless the working directory was overwritten like this:
        //
        //.pipe(phpipe({
        //    cwd: 'templates',
        //}))
        .pipe(rename(function (path) {
            path.extname = ".html";
            return path;
        }))
        .pipe(gulp.dest('compiled'));
});

This results in `compiled/base.html

<h1>Test</h1>
<h2>This is included from /path/to/current/gulp/dir/templates/inner.php</h2>

Options

You can pass options to gulp-phpipe(options)

  • phpBin: string - full path of the PHP binary you wish to use; this defaults to php which assumes that PHP is in your PATH
  • phpArgs: string[] - array of additional arguments for the PHP process; defaults to[]
  • cwd: string - the working directory of the PHP process; defaults to the base directory of the processed file
  • env: object - overrides all current environment variables and runs PHP with only the environment variables set in this object; defaults to null

License

MIT License