[英]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:这是我尝试过的:
sail artisan sail:publish
sail artisan sail:publish
发布风帆文件sail artisan sail:publish
/docker/7.4
, /docker/8.0
, /docker/8.1
/docker/7.4
, /docker/8.0
, /docker/8.1
sail php -v
I saw that I am using php 8.0.12sail php -v
我看到我正在使用php 8.0.12xdebug.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
sail build --no-cache
and restart container.sail build --no-cache
并重新启动容器。 This takes about 8 minutes. 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:为此,我尝试了以下操作:
sail shell
sail shell
登录到容器cd /etc/php/8.0/cli/conf.d/
cd /etc/php/8.0/cli/conf.d/
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.