windows php开发环境和linux 保持一致 最佳实践
由于swoole-cli 不支持 7.4 及以下版本 ,参考 自行编译7.4 参考 可以自己编译php 并加入swoole扩展。
之前 xlswriter 扩展 不支持cygwin, 后来我让ai修复了。成功编译。里面链接 我也放了含该扩展的 压缩包 。修复后的xlswriter ,其实就改一行 ioapi.c 里增加 || defined(__CYGWIN__)
--- a/ext/xlswriter/library/libxlsxwriter/third_party/minizip/ioapi.c
+++ b/ext/xlswriter/library/libxlsxwriter/third_party/minizip/ioapi.c
@@ -14,7 +14,8 @@
*/
-#if defined(__APPLE__) || defined(IOAPI_NO_64)
+#if defined(__APPLE__) || defined(IOAPI_NO_64) || defined(__CYGWIN__)
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
+// Also Cygwin uses standard functions (fopen64/ftello64/fseeko64 are not available)
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
#define FTELLO_FUNC(stream) ftello(stream)
#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)
是1.5.8 那版的源码里改,后来该扩展好像发布了2.0 还没有在cygwin里试。
总之该版本修复后 在其他php8.1 8.2 8.3 8.4 里应该都适用,希望swoole 官方人员看到,修改后编译出新的swoole-cli 给大家用。这样就不用因为xlswriter 扩展无法用,还得去提交测试环境 去 测试excel。
还有 有时候一些框架的库 如laravel-horizon 依赖 pcntl、posix、sockets linux转悠扩展的,本地composer 去装 每次都要手动 加 --ignore-platform-reqs 参数,为什么不在cygwin下装? 因为本地有chsrc 配置了镜像。
masgeek/windows-ext-ignorer扩展包就是自动识别系统是 windows 且无相关扩展忽略报错的。
当然 在过年到现在,我订阅的composer rss 里。我也看见过有替代 扩展包,就是自己通过http 实现 进程通知。不依赖那两个扩展的。具体名字记不得了。
本作品采用《CC 协议》,转载必须注明作者和本文链接
关于 LearnKu
推荐文章: