Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call to undefined method Illuminate\Http\Response::make() in Laravel 4.2?

I am using Laravel 4.2. While using make method of Response class i am getting undefined method error.

Route::get('/', function()
{
    $contents = "Hello";
    $response = Response::make($contents, 200);
    return $response;
});

Here is the error

enter image description here

like image 547
Cody Avatar asked Mar 28 '16 05:03

Cody


2 Answers

The error is absolutely correct.. make doesn't exist in the Http class, it exists as an accessor method off of the Facade class.

use Illuminate\Support\Facades\Response;

If you (for some reason) need both, just alias it.

use Illuminate\Support\Facades\Response as FacadeResponse;

Then you can just do $response = FacadeResponse::make($content, 200);

Have a gander at the docs for more information.

like image 130
Ohgodwhy Avatar answered Sep 17 '22 11:09

Ohgodwhy


The simple thing I did for this problem

return \Response::stream($callback, 200, $headers);

I put forward slash ( \ ) before Response.

like image 37
Muhammad Wajahat Anwar Avatar answered Sep 17 '22 11:09

Muhammad Wajahat Anwar