【发布时间】:2018-05-11 15:27:49
【问题描述】:
我正在尝试在我的 php 程序中配置一组用户和角色。我已按照 synfony 网站上的教程进行操作,但收到以下错误:
(1/1) 无效类型异常 路径“security.access_control.0.path”的类型无效。预期的标量,但得到了数组。 提示:使用 urldecoded 格式
Security.yml:
# To get started with security, check out the documentation:
# https://symfony.com/doc/current/security.html
security:
providers:
in_memory:
memory:
users:
inkoper:
password: inkoper
roles: 'ROLE_INKOPER'
access_control:
- { path '^/*', roles: [ROLE_INKOPER] }
encoders:
Symfony\Component\Security\Core\User\User: plaintext
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: ~
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate
http_basic: ~
# https://symfony.com/doc/current/security/form_login_setup.html
#form_login: ~
更新
感谢 Andrew Vakhniuk,我找到了问题所在。我忘了在访问控制下的路径后面加上一个 ':'。
【问题讨论】: