简体   繁体   English

如何在 Laravel 中启用 xdebug 日志?

[英]How to enable xdebug log in Laravel sail?

I am trying to enable xdebug log in Laravel 8, using the sail package for docker.我试图在 Laravel 8 中启用 xdebug 日志,使用 docker 的帆包。

According to xDebugs docs log will appear automatically when set the xdebug.log to a value.根据xDebugs docs日志将在将xdebug.log设置为一个值时自动出现。

This is what I tried:这是我尝试过的:

  1. Publish sail's files using sail artisan sail:publish使用sail artisan sail:publish发布风帆文件sail artisan sail:publish
  2. This created /docker/7.4 , /docker/8.0 , /docker/8.1这创建了/docker/7.4/docker/8.0/docker/8.1
  3. With sail php -v I saw that I am using php 8.0.12使用sail php -v我看到我正在使用php 8.0.12
  4. Now I added xdebug.log =/var/www/html/storage/app to docker/8.0/php.ini现在我将xdebug.log =/var/www/html/storage/app添加到xdebug.log =/var/www/html/storage/app docker/8.0/php.ini
  5. I run sail build --no-cache and restart container.我运行sail build --no-cache并重新启动容器。 This takes about 8 minutes.这大约需要 8 分钟。

Unfortunately, checking phpinfo() shows that xdebug.log has no value:不幸的是,检查 phpinfo() 表明xdebug.log没有价值: 在此处输入图片说明

According to my docker file, the php.ini should have been copied: COPY php.ini /etc/php/8.0/cli/conf.d/99-sail.ini so I wanted to try to read the file.根据我的 docker 文件, php.ini应该已被复制: COPY php.ini /etc/php/8.0/cli/conf.d/99-sail.ini所以我想尝试读取该文件。 To do this, I tried the following:为此,我尝试了以下操作:

  1. Log into container using sail shell使用sail shell登录到容器
  2. Go to cd /etc/php/8.0/cli/conf.d/转到cd /etc/php/8.0/cli/conf.d/
  3. Read file using cat 99-sail.ini使用cat 99-sail.ini读取文件

That is the content:那是内容:

[PHP]
post_max_size = 100M
upload_max_filesize = 100M
variables_order = EGPCS

# Extensions...
extension=swoole.so

# Zend Extensions...
zend_extension=xdebug.so

However in /docker/8.0/php.ini I have only this:但是在/docker/8.0/php.ini我只有这个:

[PHP]
post_max_size = 100M
upload_max_filesize = 100M
variables_order = EGPCS
xdebug.log =/var/www/html/storage/app

Why is that?这是为什么? I also would like to try to just edit the file directly, but vim is not known.我也想尝试直接编辑文件,但不知道vim Also the command sudo is not known, although image is ubuntu:21.04. sudo也是未知的,尽管图像是 ubuntu:21.04。 I tried to install vim, but I am missing access rights.我尝试安装 vim,但缺少访问权限。

在此处输入图片说明

COPY php.ini /etc/php/8.0/cli/conf.d/99-sail.ini

You can just add Xdebug configuration in the php.ini file that gets copied.您可以在复制的php.ini文件中添加 Xdebug 配置。 But if you update it, then you need to rebuild/restart your container.但是如果你更新它,那么你需要重建/重启你的容器。

Looks like this Laravel app used its own dockerfile.看起来这个 Laravel 应用程序使用了自己的 dockerfile。 I forgot to check docker-compose.yml .我忘了检查docker-compose.yml Inside laravel.test was build that pointed to a different file.内部laravel.test是指向不同文件的构建。 Thats why the php.ini inside docker file was not copied.这就是为什么 docker 文件中的 php.ini 没有被复制的原因。

Also I had to use a path to an actual log file and put it in quotations like this:此外,我必须使用实际日志文件的路径并将其放在这样的引号中:

xdebug.log ="/var/www/html/storage/app/xdebug.log"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM