3

I'm trying to setup Symfony3 microkelner to work with FOSRestBundle and I've faced some issues with it.

I want to use as input json or xml and as output also json or xml.

I've did some setup and I face errors:

InvalidArgumentException in ContainerBuilder.php line 766: The service definition "templating" does not exist.

and

InvalidArgumentException in ReplaceAliasByActualDefinitionPass.php line 48: Unable to replace alias "templating" with "fos_rest.templating".

This is how my config.yml looks like (parts with templating and fos_rest)

# Friends of Symfony REST
fos_rest:
  disable_csrf_role: ROLE_API
  view_response_listener: force
  force_redirects:
    html: true
      param_fetcher_listener: true
      body_listener:
        decoders:
          xml: fos_rest.decoder.xml
          json: fos_rest.decoder.json
      format_listener:
        enabled: true
        rules:
          - { path: '^/', priorities: ['json', 'xml'], fallback_format: 'json', prefer_extension: false }
      view:
        formats:
          xml: true
          json: true
        default_engine: json
        failed_validation: HTTP_BAD_REQUEST

also

templating:
    engines: ['twig']
....
# Twig Configuration
twig:
    debug:            "%kernel.debug%"
    strict_variables: "%kernel.debug%"
    exception_controller: 'FOS\RestBundle\Controller\ExceptionController::showAction'

In microkelner I use folowing bundles:

  $bundles = array(
        new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
        new FOS\RestBundle\FOSRestBundle(),
        new JMS\SerializerBundle\JMSSerializerBundle(),
        new Symfony\Bundle\TwigBundle\TwigBundle(),
    );

    if (in_array($this->getEnvironment(), array('dev', 'test'), true)) {
        $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
    }

Versions of compontents that I use:

  • FOSRestBundle: "1.7.7"
  • Symfony: "3.0.0"

The question is how to setup it properly to get rid of this error and to make Symfony3 with microkelner to work with FOSRestBundle?

Thank you.

Robert
  • 19,800
  • 5
  • 55
  • 85

1 Answers1

0

Are you sure your configuration is correct? When I dump container with:

$ bin/console debug:container | grep fos

I see among many other lines:

fos_rest.templating            alias for "templating"   

So fos_rest.templating is just an alias of templating and that's probably why you can replace it with itself and therefore those two errors.

martin
  • 93,354
  • 25
  • 191
  • 226