1

I am going to debug the variables in controller files.

But I couldn't figure out how I can debug it and show the values into front-end site or in log files.

Do you have any ideas about this?

What is your debug mode which you often use when you work in a controller?

3

You could use for example the dd() method with the craft3-dumper package. You can also use the debug toolbar. You could also use Sentry to get a nice overview about your errors with the craft sentry package. Or you could use xdebug. Or or or ... :)

So there are severals ways to debug something.

  • Note that xdebug (with PHPStorm) is by far the most powerful of these options, and will save you a lot of time. Highly recommended. – Udo Nov 15 at 7:38
  • Hey Chris, Thanks for the answer. Is there any way to log the variables without using like UI tools and additional packages? Like var_dump in php. – apollo Nov 15 at 10:28
  • Btw, one thing quickly, I have never used PHPstorm, is it a free IDE? :0 – apollo Nov 15 at 10:30
  • For a quick debug use the craft3-dumper package. I am using this a lot too. And in your controller you can just dd($var); like within laravel for example. PHPStorm is not free, but it's one of the best IDE's out there for PHP development in my opinion – Christopher Dosin Nov 15 at 10:44
  • Thanks, Chris, make sense! – apollo Nov 15 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.