0
votes

I am a beginner in Symfony2, and I am working on Symfony2 project in which a kind of general bundle, let say CoreBundle, is managing all the routes (in this form, first.domain/a-route, second.domain/a-route, third.domain/a-route,...) of the website. Now I have been creating FirstBundle, SecondBundle, ThirdBundle with the idea to "transfer" the management of routes of each subdomain (firt, second, third,...) to the related bundle.

Beginning with the transfer of routes from CoreBundle to FirstBundle by editing /app/config/routing.yml file from:

resource: "@ProjectFirstBundle/Resources/config/routing.yml"

    prefix: /

host: "{subdomain}.{domain}"

    defaults: { _controller: ProjectFirstBundle:Public:aroute }

      domain: %project_domain%

    requirements:

      domain: "%project_domain%"

      subdomain:  'first'

to:

resource: "@ProjectFirstBundle/Resources/config/routing.yml"

    prefix: /

And then creating FirstBundle/Resources/config/routing.yml file with the following content:

project_first_aroute:

    path:    /a-route

    host: "{subdomain}.{domain}"

    defaults: { _controller: ProjectFirstBundle:Public:aroute }

      domain: %project_domain%

    requirements:

      domain: "%project_domain%"

      subdomain:  'first'

And of course I have created controller and view files using the same schema as CoreBundle (by making an adaptation -- inheritance for .twig files). As the result, the following exception is being returned when running first.domain/a-route:

Fatal error: Uncaught exception 'Symfony\Component\Yaml\Exception\ParseException' with message 'Unable to parse at line 15 (near " domain: %project_domain%").' in

Any suggestions as to how I can effectively achieve my goal?

Thanks in advance for your help.

2

2 Answers

1
votes

I Came to find out that I should have created FirstBundle/Resources/config/routing.yml file as followed:

project_first_aroute:

path:    /a-route

host: "{subdomain}.{domain}"

defaults: { _controller: ProjectFirstBundle:Public:aroute, domain: "%project_domain%" }      

requirements:

  domain: "%project_domain%"

  subdomain:  'first'
0
votes

The error message is a syntax error from the Yaml Parser.

Please note that correct idention is essential in a Yaml File and check if you need to wrap %project_domain in quotes on the first occurence (see stackoverflow syntax highlighting, it looks odd).

-

Debugging routes in Symfony2

app/console router:debug