dongqian6554 2016-09-22 09:06
浏览 89

使用browserSync和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.

The problem: terminal keeps telling me "PHP server not started. Retrying...".

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']);
  • 写回答

1条回答 默认 最新

  • dongyunshan4066 2017-02-19 12:45
    关注

    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.

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

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比