Skip to content
Advertisement

How to print out value on controller Laravel?

I’m beginner on Laravel…

How to debug some value on controller in Laravel, result can show to console like syntax console.log() on javascript?

example controller function :

class TestMeController extends Controller {
    public function __construct()
    {
        $this->middleware('jsonify');
    }

    public function callMe($id)
    {
        $params = Request::all();

        console.log($id);  <== how to write code on Laravel?
    }
}

Advertisement

Answer

In Laravel use dd($id) or if you don’t want to halt the execution, you can use dump($var). You can still always use PHP’s native functions like var_dump, die and print_r.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement