- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在使用带有 PHP 调试扩展的 Visual Studio Code 来调试 Laravel 项目。但是有些断点被忽略了,我不明白为什么。我坚持认为并不是所有的断点都会被忽略。例如,方法声明处的所有断点都会被忽略,但变量声明处的断点会被命中。
我的 php.ini
的 Xdebug 部分:
xdebug.profiler_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back=1
xdebug.remote_enable = 1
xdebug.remote_port = 9000
这是我的 launch.json
:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9001,
"log": true
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
我尝试过的:
示例:“•”表示行断点。下面代码示例中的所有断点都将被忽略。
public function testCreateWhenAllParametersAreCorrectlySpecifiedReturnsCompany()
{
• $attributes = [
'business_name' => 'DANONE'
];
$address = factory(Address::class)->create();
$company = Company::create($attributes, $address);
$this->assertInstanceOf(Company::class, $company);
$this->assertDatabaseHas('companies', [
• 'address_id' => $address->id,
'business_name' => 'DANONE'
]);
}
如何让 Xdebug 与 Visual Studio Code 命中所有断点或者这是正常行为?预先感谢您的帮助。
更新 #1 (08/07/2019)
Zend 扩展路径在我的 php.ini
中指定,如下所示。
zend_extension = "/usr/local/Cellar/php@7.2/7.2.18/pecl/20170718/xdebug.so"
我尝试在我的 settings.json
中添加 php.validate.executablePath
。
更新 #2 (08/08/2019)
根据本次更新时的评论和回答,Xdebug 忽略某些行是正常行为。那么我的问题是为什么有些行会被忽略?忽略了哪些行?有官方名单吗?
最佳答案
在 PhpStorm 中运行它,但 Xdebug 在 PHP 上运行时,行为是相同的。
Xdebug 在事情“完成”时停止,在事情“完成”的那一行。这可以是函数调用、变量赋值、数据转换等。所有这些的共同点是它们必须是显式的。隐式赋值被忽略。
Xdebug 不会为放置在 Action “中”的断点暂停执行。这就是为什么您的代码中的第一个断点不会起作用,而第二个会起作用。
显式和隐式示例:
$attributes = [ // this is implicitly an array, no pausing execution
'business_name' => 'DANONE' // this is explicitly assigned a string, execution paused
];
一些截图(代码来自 Symfony 4 public/index.php
,有一些明显的添加 - 蓝色背景暂停执行“当前行”):
显然在 if()
语句中执行函数 - 它暂停
正如我们所见,断点位于该数组的所有 3 行上。但是,它唯一暂停的是键/值对的分配。这是显式完成的,数组本身是隐式声明的。
这里我们明确声明$testArray
是一个数组。所以:它暂停了。
这是完整的,可以在上面添加。类型数组的隐式设置,但键/值的显式分配。
所以:是的。
如果您放置的断点略有不同,它们就会暂停执行。不暂停隐含的是正常行为。
完成:
在本地 Apache 安装上,我有以下配置:
[XDEBUG]
zend_extension = C:\xampp\php\ext\php_xdebug-2.7.1-7.3-vc15-x86_64.dll
xdebug.remote_mode = req
xdebug.remote_connect_back = 1
xdebug.default_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.max_nesting_level = 200;
但我通常在 Docker 中运行它。在 docker-compose
PHP 镜像中:
environment:
PHP_XDEBUG_ENABLED: ${XDEBUG_ENABLED:-0}
PHP_IDE_CONFIG: ${PHP_IDE_CONFIG:-serverName=ProjectName}
XDEBUG_CONFIG: >
idekey=PHPSTORM
remote_host=${XDEBUG_REMOTE_HOST_IP:-host.docker.internal}
remote_port=${XDEBUG_REMOTE_PORT:-9000}
remote_enable=1
docker-compose up
时将应用程序中的 XDEBUG_ENABLED
环境配置设置为 1
)并且在 Dockerfile
pecl install xdebug-2.7.2 redis && \
docker-php-ext-enable xdebug redis && \
xdebug-2.7.2
替换为您想要的版本/与您的 PHP 版本兼容,check that here)编辑:根据对 OP 问题的评论进行补充。
有很多错误报告(请参阅这些评论,感谢 LazyOne 找到它们)。
他提供的最后一个 URL 很有趣,因为它是关于即将推出的 V2.8.0(目前是 2.8.0beta1,不是一般发布),他在 this ticket 中对此发表了评论。关于 Xdebug 不暂停执行隐式赋值:
I've just merged this into the master branch, which will become part of 2.8.0. I will release 2.7.2 soon (this week, today?!), and then probably next week a 2.8alpha1 release so that people can try this out.
(引用 Xdebug 作者 Derick 2019-05-06 12:49)
你可以看看changelog page或 roadmap用于 Xdebug。
路线图显示了将包含的所有功能/修复。
对于 2.8.0,它表明将添加对 IDE 的支持,以便 IDE 显示是否可以解决断点。它的当前发布日期定为 2019-09-30。
已发布
关于php - 使用 Visual Studio Code 的 Xdebug 会忽略一些断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57323475/
我正在尝试设置我的 git 配置,以便我可以使用工作环境和个人环境。 这是我的 ~.gitconfig 文件的内容(碰巧 work 和 private 在 github 上): [url "git@
我有以下情况。我在 Sheet1 上有一个项目列表,我想将项目复制到 Sheet2 并排除特定项目。 假设我在 Sheet1 上有以下项目列表: 我想将“梨”单元格留在 Sheet2 上。 它应该完全
我试图让 gcc 以不同的语言提供错误消息。但它仍然给我英文的错误信息。 我的语言环境输出 varun@varun-desktop:$ 语言环境 LANG=en_IN LC_CTYPE="es_EC.
我在 Linux x86 上使用 gcc。 我的程序将指向 C 函数的指针导出到 LLVM JIT 函数。调用约定是 cdecl。它在 Windows 上的 MingW 上运行良好。但是奇怪的事情发生
windows 上 php 的奇怪问题...我的应用程序加载了一个“核心”文件,该文件加载了一个设置文件、注册自动加载、进行初始化等。在核心文件的顶部我有 include_once("config.p
在工具|选项|调试器选项 |语言异常可以忽略特定的异常类型。是否可以为每个项目定义这个?例如在调试构建配置中(Delphi 2009 和/或 2010)? /编辑:Reported in QC 最佳答
我在一个文本框旁边有 2 个按钮,在这 2 个按钮后面还有另一个文本框。第一个文本框的 tabindex 为 1000,第一个按钮为 1001,第二个按钮为 1002。第二个文本框的 tabindex
我是 python 新手,正在尝试类型提示,但它们似乎只在某些情况下起作用。它们似乎在属性返回类型上按预期工作,但是当我尝试将整数分配给字符串值(即 self._my_string = 4)时,我没有
问题陈述 我有一些国家和这些国家的州的依赖组合框。我使用 VBA 在第一个组合框中填充唯一值,然后在第二个组合框中动态填充唯一值。该代码似乎忽略了初始传递中的条件。 例如,该代码适用于第一个国家/地区
我对 Javascript 有点陌生。我试图做到这一点,以便单击一个页面上的图像会将您带到一个新页面,并在该新页面上显示特定的 div,因此我使用 sessionStorage 来记住并使用 bool
我不确定我是否正确地处理了这个问题。 我有一个 ASP.NET MVC Web 应用程序。有 4 个主要“页面”通过单击菜单选项,可以选择一个页面,并将该页面选项存储在本地存储中。 现在,如果我刷新页
我的页面工作正常,并按预期显示日期和时间,直到我不得不添加 new Date() 以避免 momentjs deprecation warning 。现在我的约会比应有的时间晚了 5 个小时。 我该如
我需要合并一个 fork 项目。不幸的是,CVS $Id 行不同,因此我尝试的合并工具报告所有文件都不同(其中 95% 只有这一行不同) 是否有一个合并工具可以配置为忽略基于模式的行比较结果? [编辑
我是 python 新手,正在尝试类型提示,但它们似乎只在某些情况下起作用。它们似乎在属性返回类型上按预期工作,但是当我尝试将整数分配给字符串值(即 self._my_string = 4)时,我没有
我正在尝试根据 How do a send an HTTPS request through a proxy in Java? 使用代理访问 https 网页 但是我遇到了一个奇怪的问题:HttpsU
我有一个简单的 CMakeLists.txt 文件: cmake_minimum_required(VERSION 2.8.9) project (sample) add_library(Shared
这个问题在这里已经有了答案: typedef pointer const weirdness (6 个答案) 关闭 8 年前。 我有一个结构体 type_s。然后我将指向 struct type_s
我正在尝试制作一个使用 AES 256 加密的应用程序。不幸的是我无法让它工作。也许我没有完全理解密码逻辑。 所以它正在工作,但据我了解,哈希包含密码。但如果我更改密码,输出是相同的。因此,Crypt
我的文件包含一些行,例如 "This is a string." = "This is a string's content." " Another \" example \"" = " New ex
我尝试使用此查询来获取所选健身房的所有用户。 我的问题是查询忽略了这部分:ual.user_id = weekUsers.user_id 查询似乎获取了与我选择的日期匹配的所有用户 ID,而不检查该用
我是一名优秀的程序员,十分优秀!