Search code examples
phpsymfonyroutesfosrestbundle

FileLoaderException: Cannot import resource "mycontroller" from "C:/wamp/www/Symfony/app/config\routing.yml


I just followed the tutorial about single route on github for this bundle : https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Resources/doc/5-automatic-route-generation_single-restful-controller.md

But I got this error when I'm trying to load my home page: "FileLoaderException: Cannot import resource "ADC\OgppBundle\Controller\OgppRestController" from "C:/wamp/www/Symfony/app/config\routing.yml" (Class could not be determined for Controller identified by "ADC\OgppBundle\Controller\OgppRestController".)

I know this is some basic stuff but I cannot make it work. Here is the code : app/config/routing.yml

adc_rest:
    resource: ADC\OgppBundle\Controller\OgppRestController
    type: rest

ADC\OgppBundle\Controller\OgppRest.php

namespace ADC\OgppBundle\Controller;

use FOS\RestBundle\Controller\Annotations\View;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class OgppRestController extends Controller
{
    public function getProfilesAction()
   {
   } // "get_profiles" [GET] /profile/all
   public function getProfileAction($id)
   {
   } // "get_profile" [GET] /profile/{id}
}

EDIT : I tried to clear the cache in dev environment but when I do it I have the same issue.

Hope this helps


Solution

  • I don't know how FOSRestBundle works (I've never used it), but I think your controller file name is wrong, it should be OgppRestController.php, not OgppRest.php.