Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPstorm - Unable to set breakpoints in blade.php files

I'm working on a Laravel application and can debug my controller php files fine, but Id like to also debug the blade.php files. With my current setup Ive followed all of jetbrains recommend settings for Laravel, (https://confluence.jetbrains.com/display/PhpStorm/Laravel+Development+using+PhpStorm#LaravelDevelopmentusingPhpStorm-DebuggingLaravelApplicationswithPhpStorm) but it is still not allowing my to set breakpoints in the blade.php files.

What could I be missing?

like image 449
Don F Avatar asked Feb 13 '15 13:02

Don F


People also ask

How do I use breakpoints in PhpStorm?

Set method breakpointsClick the gutter at the line where the method is declared. Alternatively, place the caret at the line and press Ctrl+F8 . Alternatively, do the following: Press Ctrl+Shift+F8 or select Run | View Breakpoints from the main menu.

Why is Xdebug not working?

Xdebug cannot connect to PhpStorm This means that Xdebug tries to connect to the host and can't make the connection. To fix the issue, set xdebug. remote_connect_back=0 ( xdebug. discover_client_host=false for Xdebug 3) and make sure that xdebug.

What is Xdebug_session_start PhpStorm?

#Google Dork : inurl:?XDEBUG_SESSION_START #Summary: Xdebug is a php extension that allows to debug php pages, remotely by using DGBp protocol. - Code execution is possible through eval or property_set xdebug commands. -


4 Answers

Putting a

<?php xdebug_break(); ?>

into your blade file works pretty well. Even in my tests, PHPstorm jumps to the next PHP statement in some cases.

Why this works:

Laravel processes the blade file to a normal PHP file in the cache folder. But the PHP statement xdebug_break(); will be transferred there and cause the program to halt at the position you want it to (in the cache file).

like image 145
Alex Avatar answered Oct 13 '22 23:10

Alex


To close this question - phpstorm doesnt support this functionality at the moment. A work around provided by jetbrains support was to add *.blade.php to file type associations under PHP in the IDE settings, however, it still wasnt working for me after doing this.

It appears that they created a youtrack ticket in response to my request, if youd like to encourage jetbrains to work on this please upvote: youtrack.jetbrains.com/issue/WI-26476

like image 20
Don F Avatar answered Oct 14 '22 00:10

Don F


  1. Go to your Jetbrains IDE Settings (Ctrl+Alt+S; +,; etc.)
  2. Languages & Frameworks > PHP > Debug > Tempates
  3. Enter in Blade Debug > Cache path: \path\to\app\storage\framework\views
  4. Enjoy
like image 5
budvic Avatar answered Oct 13 '22 22:10

budvic


Even if you can get the IDE to enable breakpoints on the blade files, it won't work - Laravel composes a PHP file from the Blade file - it is this file that is eventually used when the script is run - not the Blade file.

A Work-Around

This works for PHPStorm - but something similar might be possible in other IDEs.

Laravel (5) stores the composed files under storage/framework/views. These files have random generated file names - so it may be tricky to find the file you want. An easy way is to delete all these temp files and then refresh the page you want to debug. A new file will be created. In PHPstorm you can right-click on the file and select the file's extension type. (Not sure about other IDEs)

You will now be able to set breakpoints. Obviously you will need to make the changes in the Blade file - but this will at least help you to figure out what is wrong.

**Update: Alex's solution is easier! **

like image 2
HPage Avatar answered Oct 13 '22 23:10

HPage