Start php server with livereload with gulp

0

I started my studies with gulp and I loved livereload, but I only managed with static files like this link . My goal is to start the gulp, however on the embedded php server (localhost -s Localhost: 8000) or on the server with Xampp or Lampp, instead of the server node. I saw some people commenting on a solution with browsersync and another one with gulp-connect-php I could not implement both. If you know a solution and it is not a plugin for the browser, I am grateful.

    
asked by anonymous 18.10.2015 / 19:54

1 answer

2

After a few days I was able to solve my problem using gulp-connect-php and browser-sync in gulp. In the official documentation it shows exactly an example as it is done. Here's my gulpfile.js file:

var gulp        = require('gulp');
var browserSync = require('browser-sync');
var reload      = browserSync.reload;
var connectPHP  = require('gulp-connect-php');

var paths = {
      php:['*.php'],
      css:['*.css']
    };

gulp.task('php', function(){
    gulp.src(paths.php)
    .pipe(reload({stream:true}));
});

gulp.task('watcher',function(){
    gulp.watch(paths.css).on('change', function () {
      browserSync.reload();
    });
    gulp.watch(paths.php).on('change', function () {
      browserSync.reload();
    });
});

gulp.task('php', function() {
  connectPHP.server({}, function (){
    browserSync({
      proxy: 'localhost:8000'
    });
  });
});

gulp.task('default', ['php', 'watcher']);

For those who have a problem in the deployment I created a repository in Github as an example for those with difficulty.

    
20.10.2015 / 20:56