node.js - How to pipe PHP logs from PHP server to browsersync proxy? ← (PHP, Node.js, CSS, HTML)

one text

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 another gulpfile.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 current gulpfile.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: Browsersync terminal logging screenshot 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 run php -S localhost:8010, I'm able to see those logs: enter image description here

I thought the 'stdio' flag for gulp-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.

Source