简体   繁体   English

用browserSync和gulp-connect-php进行无尽的重载

[英]Endless reload with browserSync and gulp-connect-php

I finally got around to build my own task runner but I'm stuck on a feature I really need, namely browserSync but I use php with XAMPP. 我终于找到了自己的任务运行器,但是我坚持使用了我真正需要的功能,即browserSync,但是我将php与XAMPP结合使用。

The problem: terminal keeps telling me "PHP server not started. Retrying...". 问题:终端不断告诉我“ PHP服务器未启动。正在重试...”。

Since I'm new to all this I can't seem to figure out why the server's not connecting. 由于我是这方面的新手,所以我似乎无法弄清为什么服务器未连接。 Please help? 请帮忙?

Here is my code: 这是我的代码:

// Required tasks
var gulp = require('gulp'),
   connect = require('gulp-connect-php'),
   browserSync = require('browser-sync'),
   reload = browserSync.reload;


// Php Server Tasks
gulp.task('connect', function() {
   connect.server({
      base: './',
      port: 8010,
      keepalive: true
   });
});


// Browser-Sync Tasks
gulp.task('browser-sync',['connect'], function() {
   browserSync({
      proxy: '127.0.0.1:8010',
      port: 8080,
      open: true,
      notify: false
   });
});


// Watch Tasks
gulp.task ('watch', function(){
   gulp.watch('src/sass/**/*.scss', ['styles']);
   gulp.watch('src/js/**/*.js', ['scripts']);
   gulp.watch('./templates/**/*.php', ['html']);
});


// Default
gulp.task('default', ['browser-sync', 'watch']);

Can't remember where this solution popup but thought I'd share the code as it just may help someone else: 不记得该解决方案在哪里弹出,但以为我会分享代码,因为它可能会对其他人有所帮助:

To be clear: I no longer make use of gulp-connect-php. 需要说明的是:我不再使用gulp-connect-php。

// BROWSER-SYNC TASKS
gulp.task('browser-sync', function() {
    browserSync({
        proxy: 'localhost/path/to/the/files',
        open: true,
        notify: false
    });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM