REQUIRES NODE 4 OR GREATER
Start a PHP-server
This is pretty much a gulp version of @sindresorhus's grunt-php and acts as a basic version drop-in replacement for gulp-connect, though please note not all features from gulp-connect are supported with gulp-connect-php. I am open to supporting other features and pull requests that implement them.
Uses the built-in server in PHP 5.4.0+.
$ npm install --save-dev gulp-connect-php
var gulp =connect = ;gulp;gulp;
var gulp =connect = ;let server = ;gulp;gulp;gulp;
var gulp =connect =browserSync = ;gulp;
Windows Batch file execution via a
%PATH% specified batchfile is possible, but some considerations are required.
%PATH%and executable with permissions of the invoker.
@echo offREM We specify the whole path to PHP since the working directory is that of gulp...REM unless we also changed that in our gulp callback.C:\Users\mainuser\Applications\PHP\7.0.17-NTS-VC14\php.exe %*
The port on which you want to access the webserver. Task will fail if the port is already in use.
'127.0.0.1' (usually same as
The hostname the webserver will use.
0.0.0.0 if you want it to be accessible from the outside.
From which folder the webserver will be served. Defaults to the directory of the gulpfile.
Open the server in the browser when the task is triggered.
Optionally specify the path to a router script that is run at the start of each HTTP request. If this script returns
false, then the requested resource is returned as-is. Otherwise the script's output is returned to the browser.
Example router script:
Path to the PHP binary. Useful if you have multiple versions of PHP installed.
Path to a custom
php.ini config file.
Node's stdio parameter, set it to
'ignore' to suppress all the logging into console of the php server process.
function (type, collection) : collection
type - String, either
collection - Array or Object, the initial version of the collection specified by
Return: Optionally modified version of
'null' (Which is replaced with a no-op call that returns an unmodified version of the
Enables debugging of the spawn call and its parameters.
This package comes with a NPM run-script command called
prepack. This is intended to be run before the packaging and pushing to NPM, however it is also what builds the Node 4.X compatibility script
index-compat.js. Without it the default
package.json will not execute properly.
MIT © Micah Blu