Regular Expressions 101

Community Patterns

Replace FOSUserBundle controller attributes to Symfony #[Route] attribute

1

Regular Expression
PCRE2 (PHP >=7.3)

/
\#\[.*(Get|Post|Delete|Put).*\((.*)\)
/
gm

Description

Substitute AbstractFOSRestController Routing attributes by Symfony Routing attribute #[Route]

move HTTP method to methods:['<http_method>'] and use #[Route] attribute

  • #[Rest\Get('/corbeilles')]
  • #[Rest\Post('/corbeille/restore')]
  • #[Rest\Delete(path: '/chapitres/{id}', requirements: ['id' => '\d+'])]
  • #[Rest\Delete(path: '/livres/{id}', name: 'app_livre_delete', requirements: ['id' => '\d+'])]
  • #[Get(path: '/etageres/{id}')
Submitted by anonymous - a year ago