I've a problem with Symfony2 creating Rest API and using FOS\RestBundle
When I try to generate a database or an entity… Whatever I try to generate, an error occurs.
root@symfonyRest:/var/www/Symfony# php5 app/console doctrine:database:create
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
Unrecognized options "prefer_extension" under "fos_rest.format_listener"
The problem seems to be in the config.yml
config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
framework:
#esi: ~
#translator: { fallback: %locale% }
secret: %secret%
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
[…]
sensio_framework_extra:
view: { annotations: false }
router: { annotations: true }
fos_rest:
format_listener:
prefer_extension: false
view:
view_response_listener: true
EDIT :
new config.yml with format_listener.rules
fos_rest:
view:
view_response_listener: true
format_listener:
rules:
prefer_extension: false
But I've an error too
[Symfony\Component\Config\Definition\Exception\InvalidTypeException]
Invalid type for path "fos_rest.format_listener.rules.prefer_extension". Ex
pected array, but got boolean
Anybody have a solution to my problem ? Thanks !
Have a look at the bundle's configuration reference:
You have not added the prefer_extension
under format_listener.rules
but as a direct child of format_listener
.
The correct configuration would be:
fos_rest:
format_listener:
rules:
- prefer_extension: false