2

i want to use fullcalendar.io with my Symfony2 project. The Fullcalendar sends such requests for getting Event data:

/myfeed.php?start=2013-12-01&end=2014-01-12&_=1386054751381

Symfony2 usally routes with Slashes in the URl, it only exists this route:

/myfeed/start=2013-12-01/end=2014-01-12/_=1386054751381

How can I use the Feature of Fullcalendar for Symfony2?

Here my Test-Controller:

<?php

namespace Chris\KfzBuchungBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;

class AjaxGetWeekController extends Controller
{
    public function indexAction(Request $request, $start)
    {

        $response = new Response(json_encode(array("title" => 'blub',"start" =>$start)));
        $response->headers->set('Content-Type', 'application/json');

        return $response;
    }
}

Thank you!

Mikado Joe
  • 183
  • 1
  • 1
  • 14
  • 1
    you can use JsonResponse Instead Of Response For Your Response: $response = new JsonResponse(array("title" => 'blub',"start" =>$start)); – ghanbari Dec 14 '14 at 18:54

1 Answers1

2

Even though Symfony routes are typically set up differently, you can still very easily retrieve the query string parameters. See the following:

http://symfony.com/doc/current/quick_tour/the_controller.html#getting-information-from-the-request

So in your controller all you have to do is:

$start      = $request->query->get('start');
$end        = $request->query->get('start');
$timestamp  = $request->query->get('_');

I encourage you to read the Symfony documentation as it is very thorough with many examples. Also this question has been answered already on StackOverflow with many more examples here: How to get the request parameters in symfony2

Community
  • 1
  • 1
Jason Roman
  • 8,146
  • 10
  • 35
  • 40