Search code examples
phpgulplocalhostgulp-connect

Make gulp sync php files


I want make gulp work with php files, so I search and see that I need gulp-connect-php plugin. After install it, I have tried a lot of possibilities but no success. My last code is below.

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

gulp.task('browserSync', function() {
  browserSync.init({
    // server: {
    //   baseDir: 'app'
    // },
    proxy: 'http://localhost/'
  })
})

gulp.task('connect', function() {
   connect.server({
      hostname: 'localhost',
      port: 8000,
      base: ''
   });
});

Solution

  • Thank you for reply. I solve that by changing code just like below:

    gulp.task('browserSync', function() {
        browserSync.init({
            proxy: '127.0.0.1:8000'
        });
    });
    
    gulp.task('connect-sync', function() {
      connect.server({}, function (){
        browserSync({
          proxy: '127.0.0.1:8000'
        });
      });
    
      gulp.watch('**/*.php').on('change', function () {
        browserSync.reload();
      });
    });
    

    I also changed the httpd.conf file in the wamp64 folder just like this article