带参数的路由的Symfony访问控制

时间:2017-07-23 16:08:05

标签: php symfony access-control

如何授予IS_AUTHENTICATED_ANONYMOUSLY访问包含参数的路由?

我尝试在访问控制路径中引入参数(见下文)但得到异常:The file "/vagrant/app/config/security.yml" does not contain valid YAML.

Security.yml

access_control:
      - { path: ^/api/profile/img/{id}, roles: IS_AUTHENTICATED_ANONYMOUSLY, methods: [GET] }
      - { path: ^/api, roles: ROLE_API }

Profile.php

/**
 * @Route("/api/profile/img/{id}", name="profile_img_get", requirements={"id": "\d+"})
 * @Method("GET")
 */
public function getAction($id, Request $request)
{}

0 个答案:

没有答案