Turn off firewall when developing in early stages with Symfony2?

不羁的心 提交于 2019-12-03 16:15:44

In your app/config/security.yml file, under the firewalls config option add or modify the dev...

firewalls:
    dev:
        pattern:  ^/
        security: false

The security.firewalls.dev: configuration is used in every Symfony environment (dev,test,prod)!

In Symfony 4, to achieve disabling firewalls for all routes in just dev environment, you could do something like this:

Setup:

config/packages/security.yaml:

parameters:
    # Adds a fallback SECURITY_DEV_PATTERN if the env var is not set.
    env(SECURITY_DEV_PATTERN): '^/(_(profiler|wdt)|css|images|js)/'

security:
    firewalls:
        dev:
            pattern: '%env(SECURITY_DEV_PATTERN)%'
            security: false

Override per Symfony environment:

create a new file config/packages/dev/parameters.yaml:

parameters:
    env(SECURITY_DEV_PATTERN): '^/'

Now all routes are reachable without firewall in Symfony dev environ

Override using environment variables:

You could also override SECURITY_DEV_PATTERN in the .env file:

SECURITY_DEV_PATTERN=^/

This only works if you don't include the .env in your production environment, or if you specifically override the SECURITY_DEV_PATTERN environment variable there as well.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!