kormik kormik - 1 year ago 59
PHP Question

How to add route to a controller in custom directory?

In Symfony 3 I am trying to load routing from controllers which are not in a bundle using a directory path, but parameter

is not resolved here. It works if I use absolute path.

My routing.yml file:

resource: '%kernel.root_dir%/../src/MyModule/Controller'
type: annotation
prefix: /mymodule

Do you have any suggestion how to use relative path without referencing a bundle?

Answer Source

You can use a path relative to the current config file:

resource: ../../src/MyModule/Controller

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download