Skip to content

Scan PHP files in Gulp and process include and require statements to inline HTML snippets.

License

Notifications You must be signed in to change notification settings

riklewis/php-include-html

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

Scan PHP files in Gulp and process include and require statements to inline HTML snippets. The following are all handled...

  • include
  • require
  • include_once
  • require_once

Status

NPM Version Stability Dependencies Development Dependencies Build Status Coverage Status

Requirements

  • Gulp - v3.9.1 or newer

Install

npm install php-include-html --save-dev

Examples

  • gulpfile.js
  var gulp = require("gulp");
  var pump = require("pump");
  var phpinc = require("php-include-html");
  var phpFiles = ["index.php"];

  gulp.task("php",function(cb) {
    pump([
      gulp.src(phpFiles),
      phpinc({verbose:true}),
      gulp.dest("build")
    ],cb);
  });
  • index.php
  <!DOCTYPE html>
  <html lang="en-gb">
    <head>
      <title>php-include-html</title>
<?php include("head.php");?>
    </head>
    <body>
      <!-- etc -->
    </body>
  </html>
  • head.php
      <meta name="viewport" content="width=device-width,initial-scale=1.0">
      <meta charset="UTF-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">

Configuration options

  • verbose: Will output additional messages to the console (boolean - default: false)
  • path: The base path of files if not same as gulpfile (string - default: "")

Treat me to a beer!

PayPal