我期待着从咕哝到吞咽的过渡。但是,我没有找到一种方法来为PHP文件提供肝负荷支持,例如使用挂载的网关(https://www.npmjs.org/package/gateway)。有其他插件可以使用gulp任务运行/服务器PHP吗?
发布于 2014-12-11 16:24:26
几周前我也问了同样的问题。我想在Gulp下启动一个本地PHP服务器,因为我比Grunt更喜欢语法。我还想使用PHP来包含其他HTML文件。)原来有一个‘’plugn,它的语法与'grunt-php‘插件非常相似。
https://www.npmjs.com/package/gulp-connect-php
https://www.npmjs.com/package/grunt-php
下面是我对Gulp的代码:
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
});
});我还设置了exe和ini文件位置。
如果您感兴趣,这是Grunt的代码:
php: {
watch: {
options: {
livereload: true,
bin: 'C:/php/php.exe',
ini: 'C:/php/php.ini',
base: '../development',
port: 8000
}
}
}希望能帮上忙!
发布于 2015-05-30 18:06:55
最后,我在http中使用了。最后,我的php服务任务如下所示:
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']);
});https://stackoverflow.com/questions/26226881
复制相似问题