Sasha Davydenko
Sasha Davydenko

Reputation: 904

Can't set breakpoint in PHPStorm

Everything works fine except template files. If there are some HTML in the code breakpoints just don't add.

How do I debug PHP code in template files?

I have PHPStorm 9.0 and Xdebug 2.2.3

Upvotes: 1

Views: 1851

Answers (1)

unrivaledcreations
unrivaledcreations

Reputation: 938

Somewhere along the line of code execution, a template engine is called from your controller or framework. That would be where you would set a breakpoint; then use step into... to see how your template file is being handled by the template engine itself. This is a tedious process, but depending on the framework you're using, may be your only alternative.

Having said that, I would actually recommend separating concerns by executing all PHP code in your controllers or source files; and then passing those values on to the template as simple variables or code snippets for rendering. This follows a similar convention to "dependency injection" and will make your template files easier to compose and troubleshoot.

Upvotes: 1

Related Questions