Gilberto Junior
Gilberto Junior

Reputation: 33

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: ''
   });
});

Upvotes: 2

Views: 150

Answers (1)

Gilberto Junior
Gilberto Junior

Reputation: 33

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

Upvotes: 1

Related Questions