Skip to main content

Debug your Laravel Application on PhpStrom

Debugging is the key concept while we writing thousands of lines in code. In most of the cases, developers set the breakpoints and test the code it is work as expected. 

In PHP framework like laravel, normally we are using var_dump(), echo and dd command to see the values. But do you think it is a proper way to debug? 

In this session, I give you some few steps to debug your laravel applications using PhpStrom and Xdebug. Just follow the step one by one.

Download the Xdebug and Configure with your PHP installation

Go to the Xdebug download page and download the proper version of xdebug of your PHP version. If you find difficult to find the correct version of Xdebug better go to custom installation instructions link on the same page. 

If you click the custom installation page follow the instruction to install Xdebug and configure it.

After that install the browser extension for Xdebug. 



Connect PhpStrom and Xdebug


After you finish the installation, Start your laravel project by entering the following command 

php artisan serve

then go to your browser and check it. your application is run without the debugger. 

Example: http://localhost:8000 will show your welcome page. 

After that in your browser click, the bug button appears on your web page and click Debug. Then the button appears as green. 

Then, go to your PhpStrom and click the button 
 
and it will show up as
It means the PhpStrom is listening the debugging session of the browser. 

Then setting the break point on your code and refresh the page. You will point to the breakpoint when your code is triggered. 


  

Popular posts from this blog

Missionaries & Canibal Problem in AI using Pro Log

Introduction: Missionaries and Cannibals is a notable problem in Artificial Intelligence in which three Missionaries and three Cannibals attempt to cross a river to the other side using a boat.  However, there are constraints on the problem, most notably that there can never be more Cannibals than Missionaries on either side of the river (as they will be eaten!), the boat must always take across at least one person, and the goal state is when all Missionaries and all Cannibals have successfully reached the right side of the river from the left.  Thus, with these constraints in mind, they can be programmed into Prolog fairly simply, and a solution can be searched for.