首页
留言
动态
归档
推荐
音乐
工具
Search
1
Emby公益服-上万部电影电视剧免费看
68,097 阅读
2
openwrt-docker部署lxk0301京东自动签到脚本
13,008 阅读
3
QuantumultX-京东签到撸京东豆
11,248 阅读
4
LXK0301京东签到脚本-自动提交互助码
9,699 阅读
5
微信-域名被封监测以及自动更换被封域名
9,215 阅读
随便写写
科学上网
Web开发
瞎折腾
Search
标签搜索
quantumultx
laravel
openwrt
laravel nova
laradock
telegram
DDC/CL
薅羊毛
google adsense
jd_scripts
京东签到
ubuntu
oh-my-zsh
web开发环境
nginx
工具
shadowsocks shadowsocksR
RBAC
权限管理
内网穿透
orzlee
累计撰写
46
篇文章
累计收到
596
条评论
首页
栏目
随便写写
科学上网
Web开发
瞎折腾
页面
留言
动态
归档
推荐
音乐
工具
搜索到
2
篇与
laradock
的结果
2020-12-18
laradock-xdebug与php版本不兼容
前言 今天掉坑里了,为了添加grpc-php扩展,重新build php-fpm和workspace。过程相当顺利,而且启动docker都没问题,开发过程也没发现(api 调式和开发)。知道访问laravel-admin后台页面,访问半天打不开。HTTP 502错误。 摸索过程 出现502错误开始没在意,以为是早上composer update,太慢直接手动中断了,可能缓存什么的出问题了。 刚开始没在意,直到我尝试php artisan ide-helper:gen (ide-helper开发工具)时出错了 segmentation fault php artisan ide-helper:gen。 这下真有问题了。 尝试访问其他开发站点,登录页没有问题,laravel日志也没有。 查看docker日志 docker-compose logs php-fpm 出现大量日志 看到这行感觉莫名其妙: Illuminate\Contracts\Container\BindingResolutionException: Target [Closure] is not instantiable while building [Encore\Admin\Layout\Content]. in /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php on line。 不可能会出现这种错误啊,查看源码: namespace Encore\Admin\Layout; use ... class Content implements Renderable { ... /** * Content constructor. * * @param Closure|null $callback */ public function __construct(\Closure $callback = null) { if ($callback instanceof Closure) { $callback($this); } } } 构造函数有默认值,而且参数也是个闭包,不可能出现字符串Closure被容器实例化啊。简直一脸懵逼... 想断点调试代码,xdebug也失效了。开始用gdb调试过,发现大量xdebug关键字,想着八成与它脱不了干系。 去laradock看源码,对比本地php-fmp和workspace的Dockerfile文件,虽然没有新版本发布,但是这两文件确实有改动xdebug部分。 php-fpm ########################################################################### # xDebug: ########################################################################### ARG INSTALL_XDEBUG=false RUN if [ ${INSTALL_XDEBUG} = true ]; then \ # Install the xdebug extension if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \ pecl install xdebug-2.5.5; \ else \ if [ $(php -r "echo PHP_MINOR_VERSION;") = "0" ]; then \ pecl install xdebug-2.9.0; \ else \ pecl install xdebug-2.9.8; \ fi \ fi && \ docker-php-ext-enable xdebug \ ;fi # Copy xdebug configuration for remote debugging COPY ./xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini RUN sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /usr/local/etc/php/conf.d/xdebug.ini && \ sed -i "s/xdebug.remote_enable=0/xdebug.remote_enable=1/" /usr/local/etc/php/conf.d/xdebug.ini && \ sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /usr/local/etc/php/conf.d/xdebug.ini workspace ########################################################################### # xDebug: ########################################################################### USER root ARG INSTALL_XDEBUG=false RUN if [ ${INSTALL_XDEBUG} = true ]; then \ # Install the xdebug extension if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \ pecl install xdebug-2.5.5; \ else \ if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ] && [ $(php -r "echo PHP_MINOR_VERSION;") = "0" ]; then \ pecl install xdebug-2.9.0; \ else \ if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ] && [ $(php -r "echo PHP_MINOR_VERSION;") = "1" ]; then \ pecl install xdebug-2.9.8; \ else \ if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ]; then \ pecl install xdebug-2.9.8; \ else \ #pecl install xdebug; \ echo "xDebug 3 required, not supported."; \ fi \ fi \ fi \ fi && \ echo "zend_extension=xdebug.so" >> /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/20-xdebug.ini \ ;fi # ADD for REMOTE debugging COPY ./xdebug.ini /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini RUN sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ sed -i "s/xdebug.remote_enable=0/xdebug.remote_enable=1/" /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini xdebug版本被限制在2.9.8,我去xdebug官网查看发现最新3.0.1,立马去workspace执行php -v: PHP 7.4.13 (cli) (built: Nov 28 2020 06:24:43) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.13, Copyright (c), by Zend Technologies with Xdebug v3.0.1, Copyright (c) 2002-2020, by Derick Rethans 果然是最新版本,这是laradock问题,将php-fpm和workspace Dockerfile xdebug代码段替换再 build 就能解决了。 结语 xdebug 3.x估计是对应php8,目前开发环境使用PHP7,出现这种莫名其妙的错误真的很难调试。浪费大半天时间,重新build不知道多少遍,总之记住扩展不兼容也会出现各种莫名其妙问题。
2020年12月18日
826 阅读
0 评论
0 点赞
2020-03-27
Laradock-PHPStorm开启XDebug
前言 前几天写了一篇Laradock-部署本地开发环境,使用了几天发现确实很方便。最近又折腾点东西,没有XDebug确实不顺手,网上找了不少资料和教程,有些坑和解决方案记录一下。 开搞 开启XDebug 需要laradock容器php-fpm、workspace都安装XDebug,如果已经安装则不需要管它,否则需要修改你的laradock目录\.env。 PHP_FPM_INSTALL_XDEBUG=true WORKSPACE_INSTALL_XDEBUG=true PHP_IDE_CONFIG=serverName=laradock PHP_IDE_CONFIGXDebug服务名看你自己,你想改就改,不想改默认就行。 然后再重新build docker-compose build php-fpm workspace。每次build真心漫长,就一个扩展也要整个编译,这里不得不吐槽下。强烈建议科学上网或者修改laradock源地址(修改源地址我没有验证过,不会科学上网你可以试试): # If you need to change the sources (i.e. to China), set CHANGE_SOURCE to true CHANGE_SOURCE=true # Set CHANGE_SOURCE and UBUNTU_SOURCE option if you want to change the Ubuntu system sources.list file. UBUNTU_SOURCE=aliyun 配置xdebug.ini 两处都要修改你的laradock目录\workspace\xdebug.ini、你的laradock目录\php-fpm\xdebug.ini: //xdebug.remote_host="docker.for.win.host.internal" xdebug.remote_connect_back=1 xdebug.remote_port=9000 xdebug.idekey=PHPSTORM xdebug.remote_autostart=0 xdebug.remote_enable=0 xdebug.cli_color=0 xdebug.profiler_enable=0 xdebug.profiler_output_dir="~/xdebug/phpstorm/tmp/profiling" xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.var_display_max_children=-1 xdebug.var_display_max_data=-1 xdebug.var_display_max_depth=-1 两种方法: 修改xdebug.remote_host值为Windows:docker.for.win.host.internal,MacOS:docker.for.mac.host.internal。xdebug.remote_connect_back修改为0。 注释掉xdebug.remote_host配置,不指定主机xdebug.remote_connect_back=1,让XDebug自动捕获主机。 网上很多教程说是改成xdebug.remote_host=docker.for.win.localhost或者xdebug.remote_host=docker.for.mac.localhost,这是之前的写法,巨坑。直接使用第二种方法省得坑爹。 默认xdebug.ini配置文件是不能动态修改的,每次修改都必须build,为了方便可以修改docker-compose.yml文件 ### Workspace Utilities ################################## workspace: build: context: ./workspace args: ... volumes: ... - ./workspace/xdebug.ini:/etc/php/${PHP_VERSION}/cli/conf.d/xdebug.ini ###添加磁盘挂载 ### PHP-FPM ############################################## php-fpm: build: context: ./php-fpm args: ... volumes: ... - ./php-fpm/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini ###添加磁盘挂载 ... 这样修改后可以热修改文件,就像配置nginx站点一样方便 配置PHPStorm 新建一个服务,服务名称就是这里配置的PHP_IDE_CONFIG=serverName=laradock laradock,Host填写你本地站点访问地址,开启Use path mappings,填写你的映射地址/var/www/you-project,然后OK。 点击Run菜单: 点击+添加一个PHP Remote Debug: 勾选Filter debug connection by IDE key,选择你的刚刚添加的Server,IDE key填写PHPSTORM,这个值是在xdebug.ini配置的。 再点击run, Debug 'xxx'就可以调试了。 我在调试的时候发现PHPStorm时不时断点,提示错误:Remote file path '/var/www/xxxxx artisan' is not mapped to any file path in project,这是因为XDebug也会调试php cli,如果不需要可以关掉: 进入workspace容器docker-compose exec workspace bash。 编辑cli的xdebug.ini,nano /etc/php/7.4/cli/conf.d/xdebug.ini,注意你自己的PHP版本,修改两项配置:xdebug.remote_autostart=0 xdebug.remote_enable=0 保存退出就好了,不会再调试php cli了。需要的时候再打开好了。 配置后所有laradock容器中的站点全部都有效。你可以试着访问容器中其他站点,当前项目也会进入调试模式,而且PHPStorm又出现错误:Remote file path '/var/www/xxxxx' is not mapped to any file path in project。因为当前目录映射找不到。要重新打开其他项目,配置下目录映射,然后再开启动调试,不要开多个PHPStorm一起调试,会疯掉的。 结语 在这里浪费不少时间,确实够折腾的,不过确实长记性了,最近又开始折腾Laravel nova,2018年刚出的时候确实很多不完善,一直使用Laravel admin,总得来说还是没有Laravel nova那么舒服。现在Laravel nova经过那么长时间过度已经很完善了,是时候使用Laravel nova继续折腾了。
2020年03月27日
1,695 阅读
0 评论
1 点赞