amitchhajer
amitchhajer

Reputation: 12830

Symfony2 Fos Rest showing url , giving 500 in logs

app/console router:debug shows

get_test_helloworld      GET    /test/helloworld.{_format}

but on hitting this url, nothing is displayed and in logs i get

    [2013-06-08 02:38:44] request.ERROR: Symfony\Component\HttpKernel\Exception\NotFoundHttpException:
No route found for "GET /test/helloworld" (uncaught exception) 
at /home/user/Code/app/cache/prod/classes.php line 4261 [] []

My TestController

<?php

namespace User\Bundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use FOS\RestBundle\View\View;
use FOS\RestBundle\Response\Codes;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;

class TestController extends Controller
{
    public function getTestHelloworldAction()
    {
        var_dump('hello world');die;
    }
}

I am using FosRest bundle and routing.yml have

test:
    type: rest
    resource: User\Bundle\Controller\TestController

Stuck here from long time now. Any ideas where is this going wrong?

Upvotes: 0

Views: 781

Answers (2)

user3008593
user3008593

Reputation:

Clear the cache and restart server and php. Hope this helps.

Upvotes: 2

ghostika
ghostika

Reputation: 1503

The problem that you don't have /test/helloworld route, you have only test/helloworld.html cause for format, html is the default value, id you doesn't specify otherwise. If you want to test for AJAX calls (eg format with json ) AND normal request then leave it like this, but if you will use only with html format, remove the .{_format}, cause then you don't need it.

Upvotes: 0

Related Questions