Gulp plugin to run php server?

I am looking for a transition from grunt to gulp. However, I cannot find a way to serve pen-enabled PHP files, such as gateway ( https://www.npmjs.org/package/gateway ) using mounts. Are there any plugins there to run PHP / server using gulp task?

+2
source share
2 answers

I asked the exact same question a few weeks ago. I want to run my own PHP server under Gulp because I like the syntax better than Grunt. I also want to use PHP only to include other HTML files. :) It turns out there is a plugin 'gulp -connect-php' that has very similar syntax for the plugin 'grunt-php'.

https://www.npmjs.com/package/gulp-connect-php

https://www.npmjs.com/package/grunt-php

Here is my Gulp code:

var gulp = require('gulp'), livereload = require('gulp-livereload'), connectPHP = require('gulp-connect-php'); gulp.task('connect', function() { connectPHP.server({ hostname: '0.0.0.0', bin: 'C:/php/php.exe', ini: 'C:/php/php.ini', port: 8000, base: 'dev', livereload: true }); }); 

I also set the location of the exe and ini file.

If you're interested, this is the code for Grunt:

 php: { watch: { options: { livereload: true, bin: 'C:/php/php.exe', ini: 'C:/php/php.ini', base: '../development', port: 8000 } } } 

Hope this helps!

+1
source

I ended up using gulp -connect-php with http-proxy. As a result, my php serve task looked like this:

 gulp.task('php-serve', ['styles', 'fonts'], function () { connect.server({ port: 9001, base: 'app', open: false }); var proxy = httpProxy.createProxyServer({}); browserSync({ notify: false, port : 9000, server: { baseDir : ['.tmp', 'app'], routes : { '/bower_components': 'bower_components' }, middleware: function (req, res, next) { var url = req.url; if (!url.match(/^\/(styles|fonts|bower_components)\//)) { proxy.web(req, res, { target: '{ip address taken out}:9001' }); } else { next(); } } } }); // watch for changes gulp.watch([ 'app/*.html', 'app/*.php', 'app/scripts/**/*.js', 'app/images/**/*', '.tmp/fonts/**/*' ]).on('change', reload); gulp.watch('app/styles/**/*.scss', ['styles']); gulp.watch('app/fonts/**/*', ['fonts']); gulp.watch('bower.json', ['wiredep', 'fonts']); }); 
0
source

Source: https://habr.com/ru/post/1208152/


All Articles