php / php/php-src

Log Level Filtering for PHP Built-in Server

Open
#16,855 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Feature SAPI: cli_server Status: Needs Triage
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

Hi,
We use the PHP 8.3 built-in server during development, and it has been very helpful. However, there is an excessive amount of stdout output. For every request to resources like images, JS, or CSS files, it logs messages such as Accepted, GET, Closing, etc.

Because of this, it becomes very difficult to see the stdout output or error messages from within the application itself. I couldn't find an option to filter these logs. A feature like loglevel could be helpful to manage this.

For example:
php -S 0.0.0.0:8086 -t ./public --loglevel 4

This would allow filtering logs based on levels (e.g., errors, warnings, info, etc.), making it easier to focus on application-specific outputs during development.

Additionally, the PHP built-in server outputs all logs to stderr, which seems like a bug. Ideally, standard logs should go to stdout and error messages to stderr.

PHP built-in server output like:
phpbuiltinserver

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the PHP 8.3 built-in server command path invoked by php -S, and trace how request logs and application errors are emitted. Define the expected log-level filtering and stdout/stderr behavior, then add coverage showing that selected messages are filtered and standard logs are separated from errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.