'How to include API routes and web app routes in routes.yaml file?

I have created API in my Symfony aplication and refactored structure of indexes. In this moment my api controller is in the src/api/foobar/Controller/FooBarController.php I configured my routes.yaml with controllers key but I would like to know how to include another web app (for example dashboard) in my routes.yaml. My dashboard will be on the src/Controllers/DashboardController.php Is there any option to do that?

I don't know how to correctly explain what I mean. For example - I would like to add rules for my API routes and for my Dashboard ruoutes in routes.yaml but not like this:

mobile_homepage:
    path:       /
    host:       m.example.com
    controller: App\Controller\MainController::mobileHomepage

but something like this (its only my imagine):

api_rules:
    controllers:
        resource: ../src/Api/Foobard/Controller/
        type: annotation
        prefix: '/api'
        name_prefix: 'api_'


dashboard_rules:
     controllers:
        resource: ../src/Controllers/
        type: annotation
        prefix: '/dashboard'
        name_prefix: 'dashboard_'


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source