Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想从 Symfony 的 HttpFoundation 组件中检索基本身份验证凭据。粗略查看文档一无所获;有什么办法可以做到吗?
(我在不基于 Symfony 框架的应用程序中使用 HttpFoundation 组件。)
$_SERVER['PHP_AUTH_USER']和的值$_SERVER['PHP_AUTH_PW']可以通过Symfony\Component\HttpFoundation\Request以下方式通过实例访问:
$_SERVER['PHP_AUTH_USER']
$_SERVER['PHP_AUTH_PW']
Symfony\Component\HttpFoundation\Request
$username = $request->headers->get('php-auth-user'); $password = $request->headers->get('php-auth-pw');