Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mniblett's avatar

logging to console

OK, seems simple, don't know why I can't figure this out:

In javascript I am doing console.log(['my debug message', 'second message']); How do I do the same thing in laravel (PHP)? I'm thinking there's a simple built in helper function?

My default browser is Chrome, and I have chrome dev tools installed.

0 likes
3 replies
SaeedPrez's avatar
var_dump($foo, 'bar');
dd('foo', $bar);
<script>
    console.log('{{ $foobar }}');
</script>
bobbybouwmann's avatar
Level 88

Or you can use dump which doesn't stop your application like dd() and die() does

dump('some message', 'second message');
1 like
mniblett's avatar

Thanks guys! I knew about dd(), the dump was what I was looking for.

Now maybe i can figure out what the heck is going on :)

Please or to participate in this conversation.