node.js - How to pipe PHP logs from PHP server to browsersync proxy?
Get the solution ↓↓↓Pretty straight forward. I'm successfully proxying from the default PHP server (7.4) running on my Ubuntu 20.04 laptop. Browsersync relays everything as expected to port 3000.
I found anothergulpfile.js
setup here (a little outdated):
https://garywoodfine.com/php-server-browsersync-gulp/
It's an older example; but it's somehow showing me the proxyied PHP logs in the console.
This is my currentgulpfile.js
setup based on the docs:
var gulp = require( 'gulp' ),
connect = require( 'gulp-connect-php' ),
browserSync = require( 'browser-sync' );
// "sync" script to use browsersync with local php server
gulp.task( 'sync', function() {
// Connect browsersync's server on port 3000 to proxy the PHP-fpm server on port 80
connect.server( {
port: 80,
keepalive: true,
base: 'html',
stdio: 'pipe'
}, function() {
// Proxy from the existing PHP server at localhost:80
browserSync( {
proxy: 'localhost:80',
notify: false,
open: true,
logLevel: 'debug'
} );
} );
// Watch for changes to PHP
gulp.watch( '**/*.php' ).on( 'change', function() {
browserSync.reload();
} );
// Watch for changes to CSS
gulp.watch( '**/*.css' ).on( 'change', function() {
browserSync.reload();
} );
// Watch for changes to JS
gulp.watch( '**/*.js' ).on( 'change', function() {
browserSync.reload();
} );
} );
I'd like to continue to see the PHP logs, but with this gulpfile setup, I'm only getting the Browsersync logs:
It's really helpful as a developer to get messages about which resources are loaded and whether those requests are ok (200) or not found (404) and those types of useful logs. For example, if I runphp -S localhost:8010
, I'm able to see those logs:
I thought the 'stdio' flag forgulp-connect-php
would let me see what I'm trying to see, but perhaps I'm putting that in the wrong spot..
Any help would be appreciated. Thanks.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: attempt to read property "id" on null
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.