-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Add --enable-cli-fpm to link the FPM SAPI into the CLI binary (php --fpm)
#23558
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| --TEST-- | ||
| php --fpm runs the FPM SAPI | ||
| --SKIPIF-- | ||
| <?php | ||
| include "skipif.inc"; | ||
| $php = getenv('TEST_PHP_EXECUTABLE_ESCAPED'); | ||
| if (!str_contains((string) shell_exec("$php --fpm -n -v 2>&1"), 'fpm-fcgi')) { | ||
| die("skip PHP was not built with --enable-cli-fpm"); | ||
| } | ||
| ?> | ||
| --FILE-- | ||
| <?php | ||
| $php = getenv('TEST_PHP_EXECUTABLE_ESCAPED'); | ||
|
|
||
| // As the first argument, --fpm switches to the FPM SAPI. | ||
| preg_match('/^Server API => .*$/m', shell_exec("$php --fpm -n -i"), $m); | ||
| var_dump($m[0]); | ||
|
|
||
| // Anywhere else it is an ordinary argument. | ||
| var_dump(shell_exec("$php -n -r 'echo \$argv[1];' -- --fpm")); | ||
| ?> | ||
| --EXPECT-- | ||
| string(25) "Server API => FPM/FastCGI" | ||
| string(5) "--fpm" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| PHP_ARG_ENABLE([fpm], | ||
| [for FPM build], | ||
| [AS_HELP_STRING([--enable-fpm], | ||
| [Enable building of the fpm SAPI executable])], | ||
| [no], | ||
| [no]) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,8 @@ enum fpm_init_return_status { | |
| }; | ||
|
|
||
| int fpm_run(int *max_requests); | ||
| /* this performs full fpm-SAPI boot: the former main() of php-fpm. */ | ||
| int do_php_fpm(int argc, char *argv[]); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fpm function should be prefix with fpm_
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't agree here, unless we also rename
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah cli should rename as well - it doesn't match our convention. Especially in fpm the convention is quite strict to prefix all functions with fpm_ . |
||
| enum fpm_init_return_status fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf, int run_as_root, int force_daemon, int force_stderr); | ||
|
|
||
| struct fpm_globals_s { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -131,6 +131,7 @@ static const opt_struct OPTIONS[] = { | |||||
| {'D', 0, "daemonize"}, | ||||||
| {'F', 0, "nodaemonize"}, | ||||||
| {'O', 0, "force-stderr"}, | ||||||
| {20, 0, "fpm"}, /* "php --fpm", see sapi/cli/php_cli_main.c */ | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand this - those are options for php-fpm binary so why is it added here? |
||||||
| {'-', 0, NULL} /* end of args */ | ||||||
| }; | ||||||
|
|
||||||
|
|
@@ -1495,7 +1496,7 @@ PHP_FUNCTION(fastcgi_finish_request) /* {{{ */ | |||||
| } | ||||||
| /* }}} */ | ||||||
|
|
||||||
| PHP_FUNCTION(apache_request_headers) /* {{{ */ | ||||||
| PHP_FUNCTION(fpm_apache_request_headers) /* {{{ */ | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why apache should stay in it...
Suggested change
|
||||||
| { | ||||||
| fcgi_request *request; | ||||||
|
|
||||||
|
|
@@ -1531,8 +1532,8 @@ static zend_module_entry cgi_module_entry = { | |||||
| STANDARD_MODULE_PROPERTIES | ||||||
| }; | ||||||
|
|
||||||
| /* {{{ main */ | ||||||
| int main(int argc, char *argv[]) | ||||||
| /* {{{ do_php_fpm */ | ||||||
| int do_php_fpm(int argc, char *argv[]) | ||||||
| { | ||||||
| int exit_status = FPM_EXIT_OK; | ||||||
| int c, use_extended_info = 0; | ||||||
|
|
@@ -1668,6 +1669,9 @@ int main(int argc, char *argv[]) | |||||
| force_stderr = 1; | ||||||
| break; | ||||||
|
|
||||||
| case 20: /* php --fpm */ | ||||||
| break; | ||||||
|
|
||||||
| default: | ||||||
| case 'h': | ||||||
| case '?': | ||||||
|
|
||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /* | ||
| +----------------------------------------------------------------------+ | ||
| | Copyright © The PHP Group and Contributors. | | ||
| +----------------------------------------------------------------------+ | ||
| | This source file is subject to the Modified BSD License that is | | ||
| | bundled with this package in the file LICENSE, and is available | | ||
| | through the World Wide Web at <https://www.php.net/license/>. | | ||
| | | | ||
| | SPDX-License-Identifier: BSD-3-Clause | | ||
| +----------------------------------------------------------------------+ | ||
| */ | ||
|
|
||
| #include "php.h" | ||
| #include "fpm/fpm.h" | ||
|
|
||
| int main(int argc, char *argv[]) | ||
| { | ||
| return do_php_fpm(argc, argv); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you I'm not sure this is a good idea. Does this mean that it will always created shared lib for php-fpm so it will no longer be a single binary?