title: Laravel 5 - Returned json is a simple string
body: <p>Scenario: REST api where a client requests data from server via GET method</p>
  
  <p>I am returning an array from HomeController (Server side: Laravel 5)</p>
  
  <pre><code>return ['Status' =&gt; 'Success', 'SearchResponse' =&gt; $apiresponse, 'AuthToken' =&gt; $property];
  </code></pre>
  
  <p>The above response is generated from a URL <code>http://example.com/flightSearch</code></p>
  
  <p>On the client side (Laravel 4)</p>
  
  <pre><code>        $input=Input::all();
          $url = 'http://example.com/flightSearch';
          $data = array(
               'client_id' =&gt; 'XXX',
               'api_secret' =&gt; 'YYY',
               'method'=&gt;'SearchFlight',
               'adult'=&gt;$input['adult'],
               'children'=&gt;$input['children'],
               'infant'=&gt;$input['infant'],
               'departCity'=&gt;$input['departCity'],
               'arrivalCity'=&gt;$input['arrivalCity'],
               'departDate'=&gt;$input['departDate'],
               'returnDate'=&gt;$input['returnDate'],
               'journeyType'=&gt;$input['journeyType']
               );
  
          $params = http_build_query($data);
          $result = file_get_contents($url.'?'.$params);
  
          $response = json_decode($result);
          return $response-&gt;Status //Works
          return $response-&gt;AuthToken //Works
          return $response-&gt;SearchResponse //Throws following Error
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>The Response content must be a string or object implementing __toString()
  </code></pre>
  
  <p>Solution:</p>
  
  <p>The variable <code>$apiresponse</code> was an object returned from a remote server. Adding the variable to an object solved the problem</p>
  
  <pre><code>return ['Status' =&gt; 'Success', 'SearchResponse' =&gt; array($apiresponse), 'AuthToken' =&gt; $property];
  </code></pre>