title: Use Guzzle to HTTP GET to external API with Symfony
body: <p>I am new to Symfony development so excuse me if this is a dumb question. I am trying to GET JSON data from an external API. I have tried to run a GET request via Postman and got the correct data in JSON format back so I know my URL is correct.</p>
  
  <p>I have the following code written to use Guzzle to HTTP GET a set of JSON data from my external API:</p>
  
  <pre><code>&lt;?php
  
  namespace AppBundle\Controller;
  
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  use Symfony\Component\HttpFoundation\Response;
  use Symfony\Component\HttpFoundation\Request;
  use Psr\Http\Message\ResponseInterface;
  use GuzzleHttp\Client;
  
  class ScheduleController {
  
  /**
   * @Route("/schedule")
   */
  
  public function getJobs() {
      // Create a client with a base URI
      $client = new GuzzleHttp\Client(['base_uri' =&gt; 'http://my.api.url/']);
      // Send a request to http://my.api.url/site/67/module/1449/item
      $response = $client-&gt;request('GET', 'site/67/module/1449/item');
      dump($response);
  }
  }
  </code></pre>
  
  <p>I am trying to follow along as closely as I can with <a href="http://docs.guzzlephp.org/en/latest/quickstart.html" rel="noreferrer">the Guzzle quick start guide.</a> I am getting a 500 error from this code:
  <code>Attempted to load class "Client" from namespace "AppBundle\Controller\GuzzleHttp".
  Did you forget a "use" statement for e.g. "Symfony\Component\BrowserKit\Client", "Symfony\Component\HttpKernel\Client" or "Symfony\Bundle\FrameworkBundle\Client"?</code></p>
  
  <p>I have a use statement for <code>use GuzzleHttp\Client;</code> What am I doing wrong? Is there an easier way to do this?</p>