我使用的是Symfony 2 php框架,它有几个不同的使用环境:开发、生产和测试。app.php前端控制器访问生产环境,app_dev.php前端控制器访问开发环境。熟悉Symfony的人能告诉我限制开发人员使用开发环境的最好方法是什么吗?我不希望我的web应用程序的开发版本对我的站点的用户可见,他们应该被限制为使用生产环境。
发布于 2012-04-25 03:54:02
好的,开箱即用,标准发行版在top of the dev controller上有一个基于IP的保护检查。
// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !in_array(@$_SERVER['REMOTE_ADDR'], array(
'127.0.0.1',
'::1',
))
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
然而,正如评论所指出的那样,您并不受制于这种方法。例如,如果您正在运行Apache,您可以通过add basic HTTP Authentication连接到开发和测试控制器。
https://stackoverflow.com/questions/10304907
复制相似问题