热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

PHPstorm-无法在blade.php文件中设置断点-PHPstorm-Unabletosetbreakpointsinblade.phpfiles

ImworkingonaLaravelapplicationandcandebugmycontrollerphpfilesfine,butIdliketoalso

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, (http://bit.ly/1B64Dgx) but it is still not allowing my to set breakpoints in the blade.php files.

我正在使用Laravel应用程序,可以很好地调试我的控制器php文件,但我也喜欢调试blade.php文件。在我目前的设置中,我遵循了所有的Jetbrains推荐的Laravel设置(http://bit.ly/1B64Dgx),但它仍然不允许我在blade.php文件中设置断点。

Any ideas on what I could be missing?

关于我可能遗失的任何想法?

Thanks,

谢谢,

Don

4 个解决方案

#1


39  

Putting a

放一个


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

进入你的刀片文件工作得很好。即使在我的测试中,PHPstorm在某些情况下会跳转到下一个PHP语句。

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).

Laravel将刀片文件处理为缓存文件夹中的普通PHP文件。但PHP语句xdebug_break();将被转移并导致程序在您想要的位置停止(在缓存文件中)。

#2


3  

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.

要关闭这个问题 - 目前phpstorm不支持​​此功能。由jetbrains支持提供的解决方法是在IDE设置中将* .blade.php添加到PHP下的文件类型关联,但是,在执行此操作后它仍然不适合我。

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

看来他们根据我的要求创建了一张跟踪票,如果你想鼓励喷气机使用这个请购买:youtrack.jetbrains.com/issue/WI-26476

#3


2  

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.

即使您可以让IDE在刀片文件上启用断点,它也无法工作 - Laravel从Blade文件编写一个PHP文件 - 这个文件最终在脚本运行时使用 - 而不是Blade文件。

A Work-Around

解决方法

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

这适用于PHPStorm - 但在其他IDE中可能有类似的东西。

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)

Laravel(5)将组合文件存储在storage / framework / views下。这些文件具有随机生成的文件名 - 因此找到所需的文件可能很棘手。一种简单的方法是删除所有这些临时文件,然后刷新要调试的页面。将创建一个新文件。在PHPstorm中,您可以右键单击该文件并选择文件的扩展名类型。 (不确定其他IDE)

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.

您现在可以设置断点。显然,您需要在Blade文件中进行更改 - 但这至少可以帮助您找出问题所在。

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

**更新:Alex的解决方案更容易! **

#4


0  

I devised an even better hack, which allows conditional debugging support, so that you aren't stuck with XDebug_break for the rest of eternity.

我设计了一个更好的黑客,它允许条件调试支持,这样你就不会在永恒的剩余时间里坚持使用XDebug_break。

The single line expands as follows.

单行扩展如下。


This statement has a couple of unusual features.

该声明有几个不寻常的功能。

  1. Since blade files done't have use directives, the method name, \app\utils\DebugLogger::EnableForBlades is fully qualified.
  2. 由于刀片文件没有使用指令,因此方法名称\ app \ utils \ DebugLogger :: EnableForBlades是完全限定的。
  3. Since blade files seem to lack support for the usual code blocking mechanism, the one-line statement is devoid of braces, and is terminated by a semicolon.
  4. 由于刀片文件似乎缺乏对通常的代码阻塞机制的支持,因此单行语句没有大括号,并以分号结束。

EnableForBlades is a static method that queries an environment variable (one of those defined in .local.env), returning True if that variable evaluates to True. Otherwise, it returns False, and xdebug_break is suppressed.

EnableForBlades是一个静态方法,用于查询环境变量(在.local.env中定义的变量之一),如果该变量的计算结果为True,则返回True。否则,它返回False,并禁止xdebug_break。


推荐阅读
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • IhaveconfiguredanactionforaremotenotificationwhenitarrivestomyiOsapp.Iwanttwodiff ... [详细]
  • 前景:当UI一个查询条件为多项选择,或录入多个条件的时候,比如查询所有名称里面包含以下动态条件,需要模糊查询里面每一项时比如是这样一个数组条件:newstring[]{兴业银行, ... [详细]
  • 本文讨论了如何使用IF函数从基于有限输入列表的有限输出列表中获取输出,并提出了是否有更快/更有效的执行代码的方法。作者希望了解是否有办法缩短代码,并从自我开发的角度来看是否有更好的方法。提供的代码可以按原样工作,但作者想知道是否有更好的方法来执行这样的任务。 ... [详细]
  • vue使用
    关键词: ... [详细]
  • 本文介绍了闭包的定义和运转机制,重点解释了闭包如何能够接触外部函数的作用域中的变量。通过词法作用域的查找规则,闭包可以访问外部函数的作用域。同时还提到了闭包的作用和影响。 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • 本文详细介绍了在ASP.NET中获取插入记录的ID的几种方法,包括使用SCOPE_IDENTITY()和IDENT_CURRENT()函数,以及通过ExecuteReader方法执行SQL语句获取ID的步骤。同时,还提供了使用这些方法的示例代码和注意事项。对于需要获取表中最后一个插入操作所产生的ID或马上使用刚插入的新记录ID的开发者来说,本文提供了一些有用的技巧和建议。 ... [详细]
  • 本文详细介绍了Spring的JdbcTemplate的使用方法,包括执行存储过程、存储函数的call()方法,执行任何SQL语句的execute()方法,单个更新和批量更新的update()和batchUpdate()方法,以及单查和列表查询的query()和queryForXXX()方法。提供了经过测试的API供使用。 ... [详细]
  • 本文介绍了Android 7的学习笔记总结,包括最新的移动架构视频、大厂安卓面试真题和项目实战源码讲义。同时还分享了开源的完整内容,并提醒读者在使用FileProvider适配时要注意不同模块的AndroidManfiest.xml中配置的xml文件名必须不同,否则会出现问题。 ... [详细]
  • 本文讨论了在openwrt-17.01版本中,mt7628设备上初始化启动时eth0的mac地址总是随机生成的问题。每次随机生成的eth0的mac地址都会写到/sys/class/net/eth0/address目录下,而openwrt-17.01原版的SDK会根据随机生成的eth0的mac地址再生成eth0.1、eth0.2等,生成后的mac地址会保存在/etc/config/network下。 ... [详细]
  • MyBatis多表查询与动态SQL使用
    本文介绍了MyBatis多表查询与动态SQL的使用方法,包括一对一查询和一对多查询。同时还介绍了动态SQL的使用,包括if标签、trim标签、where标签、set标签和foreach标签的用法。文章还提供了相关的配置信息和示例代码。 ... [详细]
  • 本文详细介绍了使用C#实现Word模版打印的方案。包括添加COM引用、新建Word操作类、开启Word进程、加载模版文件等步骤。通过该方案可以实现C#对Word文档的打印功能。 ... [详细]
author-avatar
手机用户2602905817_973
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有