FriendsOfSymfony / FOSRestBundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony
http://symfony.com/doc/master/bundles/FOSRestBundle/index.html
MIT License
2.79k stars 703 forks source link

You have requested a non-existent service "fos_rest.templating". #551

Closed hidabe closed 11 years ago

hidabe commented 11 years ago

I have updated to Symfony 2.3.4 and now FOSRestBundle show me error: You have requested a non-existent service "fos_rest.templating".

With this code: use FOS\RestBundle\Controller\FOSRestController; use FOS\RestBundle\View\View; class ApiController extends FOSRestController ... $data = ... $view = new View(); $view->setStatusCode(200); $view->setData($data);
return $this->handleView($view);

I dont know, i have tried many versions (dev-master, master, 0.3.1), and clear cache, etc, etc...

lsmith77 commented 11 years ago

duplicate of #548

tl;dr its a regression in Symfony2

hidabe commented 11 years ago

I dont thing it,

I have tried Symfony 2.3.3 and it dont work: You have requested a non-existent service "fos_rest.templating" again,

lsmith77 commented 11 years ago

i think i was too fast with my assessment. this does indeed seem to be something else. can you paste your configuration?

hidabe commented 11 years ago

My configuration:

imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
    - { resource: "../../vendor/sopinet/userbundle/Sopinet/UserBundle/Resources/config/config.yml" }

framework:
    #esi:             ~
    translator:      { fallback: "%locale%" }
    secret:          "%secret%"
    router:
        resource: "%kernel.root_dir%/config/routing.yml"
        strict_requirements: "%kernel.debug%"
    form:            true
    csrf_protection: true
    validation:      { enable_annotations: true }
    templating:      { engines: ['twig'] } #assets_version: SomeVersionScheme
    default_locale:  "%locale%"
    trusted_proxies: ~
    session:         ~
    default_locale: %locale%

sensio_framework_extra:
    view:
        annotations: false    

sopinet_bootstrap_extend:
    include: [ jcrop, image-gallery, xeditable, font-awesome, jqueryform, datepicker, easy-pie-chart, jquery-flot, fuelux-wizard, jquery-mask, jquery-validate, jquery-collagePlus ]

# Twig Configuration
twig:
    debug:            "%kernel.debug%"
    strict_variables: "%kernel.debug%"
    form:
        resources:
           - 'A2lixTranslationFormBundle::form.html.twig'
    globals:
      prev_label: "<"
      next_label: ">"
      first_label: "<<"
      last_label: ">>"
      base_url: %base_url%

# Assetic Configuration
assetic:
    debug:          "%kernel.debug%"
    use_controller: false
    bundles:        [ SusPasitosFrontBundle, SopinetTemplateAceBundle, FOSUserBundle, SopinetBootstrapExtendBundle ]
    #java: /usr/bin/java
    filters:
        lessphp:
            file: %kernel.root_dir%/../vendor/leafo/lessphp/lessc.inc.php
            apply_to: "\.less$"
        cssrewrite: ~
        yui_css:
            jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.2.jar"
        yui_js:
            jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.2.jar"        

# Doctrine Configuration
doctrine:
    dbal:
        driver:   "%database_driver%"
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8
        types:
            json: Sonata\Doctrine\Types\JsonType

    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        entity_managers:
            default:
                auto_mapping: true
                mappings:
                    gedmo_translatable:
                        type: annotation
                        prefix: Gedmo\Translatable\Entity
                        dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity"
                        alias: GedmoTranslatable # this one is optional and will default to the name set for the mapping
                        is_bundle: false
                    gedmo_translator:
                        type: annotation
                        prefix: Gedmo\Translator\Entity
                        dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translator/Entity"
                        alias: GedmoTranslator # this one is optional and will default to the name set for the mapping
                        is_bundle: false

stof_doctrine_extensions:
    default_locale: %locale%
    translation_fallback: true    
    orm:
        default:
            translatable: true
    uploadable:
        validate_writable_directory: true

a2lix_translation_form:
    locales: [en]       # [1]
    default_required: false      # [2] default true
    manager_registry: doctrine      # [3]
    templating: "A2lixTranslationFormBundle::default.html.twig"      # [4]

# Swiftmailer Configuration
# Swiftmailer Configuration
swiftmailer:
    transport: %mailer_transport%
    host:      smtp.gmail.com
    port:      465
    username:  %mailer_user%
    password:  %mailer_password%
    spool:
        type:                 file
        path:                 "%kernel.cache_dir%/swiftmailer/spool"

# app/config/config.yml
sonata_block:
    default_contexts: [cms]
    blocks:
        sonata.admin.block.admin_list:
            contexts:   [admin]
        sonata.block.service.text:
        sonata.block.service.action:
        sonata.block.service.rss:
        sonata.block.service.tableinput:

sonata_admin:
    title:      Questforme - AdminPanel
    templates:
        ## default global templates
        layout:  SonataAdminBundle::standard_layout.html.twig
        ajax:    SonataAdminBundle::ajax_layout.html.twig

        ## default actions templates, should extend a global templates
        list:    SonataAdminBundle:CRUD:list.html.twig
        show:    SonataAdminBundle:CRUD:show.html.twig
        edit:    SonataAdminBundle:CRUD:edit.html.twig

    dashboard:
        blocks:
            - { position: left, type: sonata.block.service.text, settings: { content: "<h2>Administración de Cuestionarios</h2><p>Desde aquí podrá administrar todos los cuestionarios: Bloques, Quest, Preguntas, Respuestas, Tipo de Respuestas...</p>"} }
            - { position: left,  type: sonata.admin.block.admin_list, settings: { groups: [Cuestionarios] } }
            - { position: right,  type: sonata.block.service.tableinput, settings: { groups: [Tabla de Reglas] } }          

fos_user:
    db_driver: orm
    firewall_name: main
    user_class: Application\Sonata\UserBundle\Entity\User        

services:
    encoderback:
        class: SusPasitos\CoreBundle\Service\EncoderBack

    containeraware:
        class: SusPasitos\FrontBundle\Menu\Builder
        arguments: [ @doctrine.orm.default_entity_manager ]

knp_menu:
    twig:  # use "twig: false" to disable the Twig extension and the TwigRenderer
        template: SopinetTemplateAceBundle:Element:knp_menu.html.twig

knp_paginator:
    page_range: 5                      # default page range used in pagination control
    default_options:
        page_name: page                # page query parameter name
        sort_field_name: sort          # sort field query parameter name
        sort_direction_name: direction # sort direction query parameter name
        distinct: true                 # ensure distinct results, useful when ORM queries are using GROUP BY statements
    template:
        #pagination: SusPasitosFrontBundle:Common:pagination_bootstrap.html.twig     # sliding pagination controls template
        sortable: KnpPaginatorBundle:Pagination:sortable_link.html.twig # sort link template        
#services:
#    questforme.listener:
#        class: Questforme\CoreBundle\Listener\LocaleListener
#        arguments: [%locale%, '@service_container', '@session']        
#        tags:
#            -  { name: kernel.event_subscriber }          
lsmith77 commented 11 years ago

you have no configuration for the FOSRestBundle?

hidabe commented 11 years ago

No, i dont

lsmith77 commented 11 years ago

hmm i cannot explain this .. fos_rest.templating should always be defined and defaults to be an alias to the templating service.

the alias is set here: https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/DependencyInjection/FOSRestExtension.php#L64

and the default is enforced here: https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/DependencyInjection/Configuration.php#L71

can you try to debug this?

hidabe commented 11 years ago

Lol, it work now

I have replaced bootstrap.app.cache generate from Symfony 2.2.x by file in Symfony 2.3.4 (new installation), and error solved.

I dont know :S

lsmith77 commented 11 years ago

heh ok