Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

man php does not mention router script usage. #10964

Closed
ash-m opened this issue Mar 28, 2023 · 3 comments
Closed

man php does not mention router script usage. #10964

ash-m opened this issue Mar 28, 2023 · 3 comments
Labels
Category: Documentation This is for documentation inside php-src, not on php.net SAPI: cli_server Status: Verified

Comments

@ash-m
Copy link

ash-m commented Mar 28, 2023

Description

The current documentation for man php (relevant parts):

php(1)                                       Scripting Language                                      php(1)

NAME
       php - PHP Command Line Interface 'CLI'

       php-cgi - PHP Common Gateway Interface 'CGI' command

SYNOPSIS
       [-- snip --]

       php [options] -S addr:port [-t docroot]

DESCRIPTION
       [-- snip --]

       PHP also contains an built-in web server for application development purpose. By using the -S option
       where addr:port point to a local address and port PHP will listen to HTTP requests on  that  address
       and port and serve files from the current working directory or the docroot passed by the -t option.

       [-- snip --]

OPTIONS
       [-- snip --]

       --server addr:port
       -S addr:port   Start built-in web server on the given local address and port

       --docroot docroot
       -t docroot     Specify the document root to be used by the built-in web server

The documentation says:

If a PHP file is given on the command line when the web server is started it is treated as a "router" script. The script is run at the start of each HTTP request. If this script returns false, then the requested resource is returned as-is. Otherwise the script's output is returned to the browser.

There is no mention of the router script in the man, nor does this really specify how it interacts with -t.

PHP Version

PHP 8.1.17

Operating System

Ubuntu 22.04.2 LTS

@iluuu1994
Copy link
Member

The documentation could be improved. Basically, any request first goes to the router. The router may decide to return false from the script. If it does, the CLI server falls back to the default behavior, looking up the file relative to the document root you've specified via -t.

@iluuu1994 iluuu1994 added Category: Documentation This is for documentation inside php-src, not on php.net SAPI: cli_server Status: Verified and removed Bug Status: Needs Triage labels Apr 1, 2023
@ash-m
Copy link
Author

ash-m commented Apr 11, 2023

@iluuu1994 Thank you. But just to clarify (as it seems from TIASing), -t has no effect on the router path, correct? ie cd /home/ash-m; php -S 0.0.0.0:8080 -t /srv/app public/router.php does not look for the router at /srv/app/public/router.php; it is only relative to the directory the command is run from (in this case, /home/ash-m/public/router.php), correct?

@ash-m ash-m closed this as completed Apr 11, 2023
@ash-m ash-m reopened this Apr 11, 2023
@iluuu1994
Copy link
Member

Yes, the path does not affect the router path.

alexandre-daubois added a commit to alexandre-daubois/php-src that referenced this issue Aug 2, 2023
alexandre-daubois added a commit to alexandre-daubois/php-src that referenced this issue Aug 2, 2023
alexandre-daubois added a commit to alexandre-daubois/php-src that referenced this issue Aug 3, 2023
nielsdos added a commit that referenced this issue Aug 3, 2023
* PHP-8.1:
  Fix GH-10964: Improve `man` page about the built-in server
  Fix GH-11438: mysqlnd fails to authenticate with sha256_password accounts using passwords longer than 19 characters
nielsdos added a commit that referenced this issue Aug 3, 2023
* PHP-8.2:
  Fix GH-10964: Improve `man` page about the built-in server
  Fix GH-11438: mysqlnd fails to authenticate with sha256_password accounts using passwords longer than 19 characters
jorgsowa pushed a commit to jorgsowa/php-src that referenced this issue Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Documentation This is for documentation inside php-src, not on php.net SAPI: cli_server Status: Verified
Projects
None yet
Development

No branches or pull requests

2 participants