title: Symfony2: Echoing JSON From a Controller for Use in an ExtJS 4 Grid
body: <p>I'm just getting started with Symfony2 and I'm trying to figure out what the correct approach is for echoing out JSON from a controller (e.g., <code>People</code>) for use in an ExtJS 4 grid.</p>
  
  <p>When I was doing everything using a vanilla MVC approach, my controller would have method called something like <code>getList</code> that would call the <code>People</code> model's <code>getList</code> method, take those results and do something like this:</p>
  
  <pre><code>&lt;?php
  class PeopleController extends controller {
      public function getList() {
          $model = new People();
          $data = $model-&gt;getList();
          echo json_encode(array(
              'success' =&gt; true,
              'root' =&gt; 'people',
              'rows' =&gt; $data['rows'],
              'count' =&gt; $data['count']
          ));
      }
  }
  ?&gt;
  </code></pre>
  
  <ul>
  <li>What does this kind of behavior look like in Symfony2?</li>
  <li>Is the controller the right place for this kind of behavior?</li>
  <li>What are the best practices (within Symfony) for solving this kind of problem?</li>
  </ul>