Reputation: 163
my gulp file:
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
//server
gulp.task('run', function() {
browserSync.init({
proxy: "http://localhost/test-site/"
});
gulp.watch("./*.php").on('change', browserSync.reload);
});
when running gulp run
from terminal it's fire the browser and shows the page as expected but without the "connected to browserSync" msg and when saving some changes the gulp watch fires and the terminal shows [BS] Reloading Browsers...
but the browser not refreshing the page
now on the other hand when i'm changing the file extension to "html" and gulp watch to gulp.watch("./*.html").on('change', browserSync.reload);
it all work as expected: when running the task it's fire the browser, this time with the "connected to browserSync" msg and when saving some changes it refresh the page.
early today i did manage to refresh the page on php file change but i lost it and can't find the reason why it's not working any more, i couldn't find any post about it on google
any ideas ?
Upvotes: 2
Views: 2529
Reputation: 37100
Create reload
and projectPHPWatchFiles
objects
var projectPHPWatchFiles = './**/*.php'; // Path to all PHP files.
var reload = browserSync.reload; // For manual browser reload.
Then in your watch process, add this
gulp.watch( projectPHPWatchFiles, reload); // Reload on PHP file changes.
And it will start refreshing on changes. If you use WordPres, I have a handy repo for WPGulp which takes care of all this.
Upvotes: 3