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:
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:
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
See also:
About the technologies asked in this question PHP PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.https://www.php.net/
Node.js Node.js is an open source server-side framework built on top of the Google Chrome JavaScript Engine. The number of sites using NodeJS has increased by 84,000. It is one of the busiest cross-platform JavaScript runtimes. Node.js is an asynchronous, single-threaded, non-blocking I / O model that makes it lightweight and efficient. The Node.js package ecosystem, npm, is also the world's largest open source library ecosystem.https://nodejs.org/
CSS CSS (Cascading Style Sheets) is a formal language for describing the appearance of a document written using a markup language.
It is mainly used as a means of describing, decorating the appearance of web pages written using HTML and XHTML markup languages, but can also be applied to any XML documents, such as SVG or XUL.https://www.w3.org/TR/CSS/#css
HTML HTML (English "hyper text markup language" - hypertext markup language) is a special markup language that is used to create sites on the Internet.
Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone.https://www.w3.org/html/
Welcome to programmierfrage.com
programmierfrage.com is a question and answer site for professional web developers, programming enthusiasts and website builders. Site created and operated by the community. Together with you, we create a free library of detailed answers to any question on programming, web development, website creation and website administration.
Get answers to specific questions
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Help Others Solve Their Issues
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.