PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, February 9, 2022

[FIXED] Multiple subdirectories for controllers in annotations.yaml

 February 09, 2022     php, symfony, symfony-routing     No comments   

Issue

I'm am trying to organize my controllers a bit more in a Symfony 5.3 application. They are in a couple of subdirectories and use annotations for their routing. Here are some samples:

  • ../src/StuffA/Controller/ControllerA.php
  • ../src/StuffB/Controller/ControllerB.php

I now want to specify both inside my annotations.yaml. I tried several approaches, but could not find anything that works:

Wildcards - Does not work

controllers:
    resource: '../../src/*/Controller'
    type: annotation

Multiple Paths - Does not work

controllers:
    resource: '../../src/{StuffA,StuffB}/Controller'
    type: annotation

Single Paths - Works but only for one Controller

controllers:
    resource: '../../src/StuffA/Controller'
    type: annotation

Any hint on what I'm doing wrong?


Solution

Just create multiple resource keys.

E.g.:

# annotations.yaml
controllersFoo:
    resource: ../../src/Foo/Controller/
    type: annotation

controllersBar:
    resource: ../../src/Bar/Controller/
    type: annotation

I don't think you can use wildcards or glob patterns with the annotation loader.



Answered By - yivi
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing