无法导入资源错误

时间:2012-06-21 16:55:00

标签: php symfony

我刚刚安装了FOSRestBundle,当我运行cache:clear

时出现此错误
[Symfony\Component\Config\Exception\FileLoaderLoadException]

  Cannot import resource "/Users/gitek/www/hotel/src/Gitek/RegistroBundle/Resources/config/routing_incidencia.yml" from "/Users/gitek/www/hotel/app/config/routing.yml".  


  [RuntimeException]                                                                                                                                                                                                                                                                                         

  The autoloader expected class "Gitek\RegistroBundle\Controller\IncidenciaController" to be defined in file "/Users/gitek/www/hotel/app/../src/Gitek/RegistroBundle/Controller/IncidenciaController.php". The file was found but the class was not in it, the class name or namespace probably has a typo.  

这是我的控制者:

<?php

namespace Gitek\RegistroBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use FOS\RestBundle\View\View;
use Gitek\RegistroBundle\Entity\Registro;
use Gitek\HotelBundle\Entity\Incidencia;

class UsuarioController extends Controller
{

    public function putIncidenciaAction($registro_id, $incidencia_id)
    {
        $em         = $this->get('doctrine')->getEntityManager();
        $registro   = $em->getRepository('RegistroBundle:Registro')->find($registro_id);
        $incidencia = $em->getRepository('HotelBundle:Incidencia')->find($incidencia_id);

        $request = $this->getRequest();

        $registro->setIncidencia($incidencia);
        $em->persist($registro);
        $em->flush();

        $view = View::create();
        $view->setData($registro);

        return $view;
    } // "put_incidencia"     [PUT] /incidencia/{registro_id, incidencia_id}

}

这是我的#app / config / routing.yml

incidencias:
    resource: "@RegistroBundle/Resources/config/routing_incidencia.yml"
    prefix:   /
    type: rest

这是我的#src / Gitek / RegistroBundle / Resources / config / routing_incidencia.yml

incidencia:
    type:     rest
    resource: Gitek\RegistroBundle\Controller\IncidenciaController
    name_prefix:  api_

最后,这是我在#app / config.yml上的fos_rest配置:

fos_rest:
    routing_loader:
        default_format: null
    view:
        default_engine: twig
        force_redirects:
            html: true
        formats:
            json: true
            xml: true
        templating_formats:
            html: true
        view_response_listener: 'force'
        failed_validation: HTTP_BAD_REQUEST
    exception:
        codes: ~
        messages: ~
    body_listener:
        decoders:
            json: fos_rest.decoder.json
            xml: fos_rest.decoder.xml
    format_listener:
        default_priorities: [json, html, '*/*']
        fallback_format: html
        prefer_extension: true
    service:
        router: router
        templating: templating
        serializer: serializer
        view_handler: fos_rest.view_handler.default  

任何帮助或线索??

1 个答案:

答案 0 :(得分:2)

您的控制器类应命名为IncidenciaController,而不是UsuarioController