symfony2 JsonResponse


Example

Return JSON formated response:

use Symfony\Component\HttpFoundation\JsonResponse;

public function someAction(){
    
    // Action's code

    $data = array(
        // Array data
    );

    return new JsonResponse($data); 
}