webman 里面使用$_SERVER里面怎么什么参数都没有
print_r($_SERVER);
输出参数很多都没有
Array
(
[COMMAND_MODE] => unix2003
[HOME] => /Users/junweiluo
[__CF_USER_TEXT_ENCODING] => 0x1F5:0x19:0x34
[LOGIN_SHELL] => 1
[PATH] => /usr/local/mysql/bin:/usr/local/opt/php@7.4/sbin:/usr/local/opt/php@7.4/bin:/usr/local/mysql/bin:/usr/local/opt/php@7.4/sbin:/usr/local/opt/php@7.4/bin:/Users/junweiluo/opt/anaconda3/bin:/Users/junweiluo/opt/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
[USER] => junweiluo
[SSH_AUTH_SOCK] => /private/tmp/com.apple.launchd.GlhUgQ8FEq/Listeners
[__INTELLIJ_COMMAND_HISTFILE__] => /Users/junweiluo/Library/Application Support/JetBrains/PhpStorm2020.3/terminal/history/history-822
[TMPDIR] => /var/folders/81/hwj2hq1j4g11sr1yzwf32yfr0000gn/T/
[SHELL] => /bin/zsh
[LOGNAME] => junweiluo
[XPC_SERVICE_NAME] => 0
[LC_CTYPE] => zh_CN.UTF-8
[XPC_FLAGS] => 0x0
[__CFBundleIdentifier] => com.jetbrains.PhpStorm
[TERM] => xterm-256color
[TERMINAL_EMULATOR] => JetBrains-JediTerm
[SHLVL] => 1
[PWD] => /usr/local/var/www/risk-control-api
[OLDPWD] => /usr/local/var/www/risk-control-api
[CONDA_EXE] => /Users/junweiluo/opt/anaconda3/bin/conda
[_CE_M] =>
[_CE_CONDA] =>
[CONDA_PYTHON_EXE] => /Users/junweiluo/opt/anaconda3/bin/python
[CONDA_SHLVL] => 1
[CONDA_PREFIX] => /Users/junweiluo/opt/anaconda3
[CONDA_DEFAULT_ENV] => base
[CONDA_PROMPT_MODIFIER] => (base)
[_] => /usr/local/opt/php@7.4/bin/php
[PHP_SELF] => start.php
[SCRIPT_NAME] => start.php
[SCRIPT_FILENAME] => start.php
[PATH_TRANSLATED] => start.php
[DOCUMENT_ROOT] =>
[REQUEST_TIME_FLOAT] => 1680081333.9622
[REQUEST_TIME] => 1680081333
[argv] => Array
(
[0] => start.php
[1] => start
)
[argc] => 2
)
这个超全局变量在webman没用的
那怎么办,目前项目需要很多数据都在$_SERVER里面
你可以使用中间件把需要用到的参数注入
$_SERVER
中,例子如下:app/middleware/ServerArgsInject.php
,内容如下:config/middleware.php
,引入中间件: