I m trying to make a Rest Api in Symfony 2.3 using FOSRestBundle. I have followed the instructions from here http://obtao.com/blog/2013/05/create-rest-api-in-a-symfony-application/
I am able to include the route_rest.xml The DocumentRestController.php contents are
namespace Demo\ListBundle\Controller;
use FOS\RestBundle\Controller\Annotations\View; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\Security\Core\Exception\AccessDeniedException;
class DocumentRestController extends Controller {
// "get_document" [GET] /document/id
public function getDocumentAction($id)
{
$document = $this->getDoctrine()->getRepository('ListBundle:Document')->find($id);
if(!is_object($document)){
throw $this->createNotFoundException();
}
return $document; } }
I get this in route debug
api_v1_get_document GET ANY ANY /api/v1/documents/{id}.{_format}
But when i access the page i get route not found.
Thanks
Thank you Guys, I finally figured it out. I was adding an extra slash in the URI while doing copy paste from
php app/console router:debug | grep api
It was a silly mistake and took me long time to figure it out.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.