[英]Symfony 2 app.php vs app_dev.php
I'm using the Symfony 2 php framework, which has a couple of different usage environments: development, production and test. 我正在使用Symfony 2 php框架,该框架具有几个不同的使用环境:开发,生产和测试。 The app.php front controller accesses the production environment and the app_dev.php front controller accesses the development environment.
app.php前端控制器访问生产环境,而app_dev.php前端控制器访问开发环境。 Can anyone familiar with Symfony advise what is the best way to restrict the development environment to developers?
任何熟悉Symfony的人都可以建议将开发环境限制为开发人员的最佳方法是什么? I don't want the development version of my web application to be viewable by users of my site, they should be restricted to using the production environment.
我不希望网站的用户可以查看Web应用程序的开发版本,应该限制他们使用生产环境。
Well, out of the box, the standard distribution has an IP-based guard check at the top of the dev controller . 好的,现成的标准发行版在dev控制器的顶部具有基于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.');
}
However, as the comments indicate, you aren't beholden to that approach. 但是,正如评论所表明的那样,您并不喜欢这种方法。 For example, if you're running Apache, you can add basic HTTP Authentication to the dev and test controllers.
例如,如果您正在运行Apache,则可以向开发和测试控制器添加基本的HTTP身份验证 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.