在 MAMP 上安装 YAML Pecl PHP 扩展

发布于 2024-11-24 02:32:28 字数 1973 浏览 1 评论 0原文

我正在通过 Git 与许多开发人员一起开发一个项目,现有代码库使用 PECL YAML PHP 扩展 (v1.0.1)。

我已经尝试了许多步骤在我的 MAMP 服务器上安装 PECL YAML 扩展,但没有什么结果!

我假设其他开发人员都在 Linux 上。

前几次安装尝试在我的 php_error_log 中发现了此错误:

"[16-Jul-2011 11:29:13] PHP 警告:PHP 启动:无法加载动态库 '/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non -zts-20090626/yaml.so'- dlopen(/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/yaml.so, 9):没有找到合适的图像: /Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/yaml.so:mach-o,但第 0 行“未知”中的架构错误”

经过大量时间谷歌搜索我意识到我并不孤单,这是因为我使用“./pecl i yaml”编译的扩展是64位版本

“file yaml.so”: yaml.so:Mach-O 64 位捆绑包 x86_64

但是,将此与我的 MAMP 设置(即“文件 xdebug.so”)上的工作扩展进行比较:

xdebug.so:具有 2 种架构的 Mach-O 通用二进制文件
xdebug.so(用于架构 ppc):Mach-O 捆绑 ppc
xdebug.so(适用于 i386 架构):Mach-O 捆绑包 i386

因此,我发现了许多博客来帮助我确定确切的问题。

无法在 32 位 MAMP 服务器上运行 64 位扩展 - 这是有道理的。

我的安装过程是:

  • 下载 PECL YAML 源
  • 提取 tar 和 cd 到模块
  • 目录中的模块源 phpize
  • 使用博客中的命令运行 .configure:

    <块引用>

    "CFLAGS='-O3 -fno-common -arch i386 -arch x86_64 -g -Os' LDFLAGS='-O3 -arch i386 -arch x86_64′ CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64 -g -Os' ./configure --disable-dependency-tracking --disable-shared-enable-static"

  • make

  • 将创建的模块从modules/yaml.so复制到MAMP <块引用>

    “sudo cp module/yaml.so /Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/。”

上述解决方案似乎对除了我之外的所有人都有效。

我的错误日志现在报告如下:

[16-Jul-2011 11:09:25] PHP 警告:PHP 启动:第 0 行未知中的无效库(可能不是 PHP 库)“yaml.so”

我现在已经在这上面花了几个小时了需要你的帮助。

我实际上想做的就是用 PHP 解析 YAML。

我有 2 个选择:

  1. 修复它并松一口气

  2. 改用 PHP YAML 解析类并在将来避免此扩展

选项 2 的问题是,由于我无法安装扩展,代码库将发生变化。

任何建议或解决方案将不胜感激。

干杯

I'm working on a project with a number of developers over Git and the existing codebase uses PECL YAML PHP extension (v1.0.1).

I have tried a number of steps to install the PECL YAML extension on my MAMP server and to no joy!

I am assuming the other developers are on Linux.

First couple of attempts at install revealed this error in my php_error_log:

"[16-Jul-2011 11:29:13] PHP Warning: PHP Startup: Unable to load dynamic library '/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/yaml.so' - dlopen(/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/yaml.so, 9): no suitable image found. Did find:
/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/yaml.so: mach-o, but wrong architecture in Unknown on line 0"

After a large amount of time googling I realised that I wasn't alone and it's because my extension that I compiled using "./pecl i yaml" was a 64 bit version

"file yaml.so":
yaml.so: Mach-O 64-bit bundle x86_64

However, comparing this to working extensions on my MAMP setup i.e. "file xdebug.so":

xdebug.so: Mach-O universal binary with 2 architectures
xdebug.so (for architecture ppc): Mach-O bundle ppc
xdebug.so (for architecture i386): Mach-O bundle i386

So I discovered a number of blogs that helped me to identify the exact problem.

Can't run 64 bit extensions on 32 bit MAMP server - makes sense.

My install process is:

  • download PECL YAML source
  • extract tar and cd into module source
  • phpize inside module directory
  • run .configure using a command from blogs:

    "CFLAGS='-O3 -fno-common -arch i386 -arch x86_64 -g -Os' LDFLAGS='-O3 -arch i386 -arch x86_64′ CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64 -g -Os' ./configure –-disable-dependancy-tracking –-disable-shared -enable-static"

  • make

  • copy created module from modules/yaml.so to MAMP:

    "sudo cp modules/yaml.so /Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/."

The above solution seems to have worked for everyone but me.

My error log now reports this:

[16-Jul-2011 11:09:25] PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'yaml.so' in Unknown on line 0

I've spent a good couple of hours on this now and need your help.

All I'm actually trying to do is parse YAML in PHP.

I have 2 options:

  1. Fix it and breath a sign of relief

  2. Use a PHP YAML parsing class instead and avoid this extension in the future

The issue with option 2 is that the codebase will change due to my inability to install an extension.

Any advice or a solution would be greatly appreciated.

Cheers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

明月松间行 2024-12-01 02:32:28

如果您安装了 Homebrew,那么您可以执行以下操作:

brew install libyaml --universal

否则安装最新的 libyaml.

您可以为 32 和 32 构建64 位 Intel,将 CFFLAGSLDFLAGS 设置为 -arch i386 -arch x86_64

然后,安装 PEAR/PECL(您也可以按照说明进行操作 此处

wget http://pear.php.net/go-pear.phar
sudo php -d detect_unicode=0 go-pear.phar

默认情况下,它将安装在 ~/pear/ 目录中。现在运行

sudo ~/pear/bin/pecl install yaml

然后,处理so文件。


这篇好文章将演示如何手动安装 MAMP 堆栈。

If you have Homebrew installed then you can do:

brew install libyaml --universal

Otherwise install the latest libyaml.

You can build for both 32 & 64 bit Intel by setting CFFLAGS and LDFLAGS to -arch i386 -arch x86_64.

Then, install PEAR/PECL (you can also follow the instructions here)

wget http://pear.php.net/go-pear.phar
sudo php -d detect_unicode=0 go-pear.phar

By default it'll install in ~/pear/ directory. Now run

sudo ~/pear/bin/pecl install yaml

Then, take care of the so file.


This nice article will demonstrate how you can install MAMP stack manually.

总以为 2024-12-01 02:32:28

嗯,这并不能真正解决你的问题。但如果你只想解析 YAML,我建议使用 Symfony YAML 类,它是一个用于解析 YAML 的易于使用的类。速度还可以,错误信息也很清楚。

是的,它会改变代码库,但这并不是一件坏事。我认为,当您可以避免使用这样的 PECL 扩展时,这是一个优点,因为您现在遇到的问题,如果您需要切换到其他服务器,您会很高兴您不必检查/安装 25 个 PECL 扩展(及其正确版本)。

所以我的建议是,切换到 YAML 类。这将使生活更轻松! :)

Well, it's not a real solution to your problem. But if you only want to parse YAML I would suggest to use the Symfony YAML class, it's a great easy to use class for parsing YAML. Speed is okay and error messages are quite clear.

Yes, it will change the codebase, but that isn't a bad thing. I think it's a plus when you can avoid using a PECL extension like this, because of the issues you now experience and if you ever need to switch to another servers you will be glad you don't have to check/install 25 PECL extensions (and their correct versions).

So my suggestion, switch to a YAML class. It will make life easier! :)

逆流 2024-12-01 02:32:28

并非所有 C 代码都是可移植的。 pecl 扩展可能存在可移植性问题,因为它可能旨在在 Linux 上运行。

如果您足够大胆,您可以找出错误所在,修复它并将修复结果提交给扩展作者。

如果没有,那么使用纯 PHP 解决方案可能是最佳选择。

另外,如果您只是在 Mac 上作为开发环境运行代码,那么您可能不需要它工作,如果:1)生产是 Linux 或 2)该功能不是功能的核心

但是,根据我的经验,我发现最好让您的开发环境与生产环境具有相同的操作系统和发行版。我会使用 VirtualBox 在虚拟机中运行 Linux,然后通过 SAMBA 或 NFS 映射文件。

希望有帮助...

Not all C code is portable. It's possible that the pecl extension has portability issues as it was probably intended to be run on linux.

If you're feeling bold, you could find out what the error is, fix it and submit the fix to the extension authors.

If not, then using a pure PHP solution might be the way to go.

Also, if you just run the code on your Mac as a dev environment, then you may not require it to work if: 1) production is linux or 2) the feature is not core to the functionality

However, in my experience, I find it's best to have your dev environments the same operating system and distro as your production box. I'd use VirtualBox to run linux in a VM, then map the files over SAMBA or NFS.

Hope that helps...

怎樣才叫好 2024-12-01 02:32:28

基于成功克服围绕 MAMP 和其他 .so 模块的问题:[相同类型的错误]

步骤 1:确保您的 MAMP 是版本 2,因为它包含通用二进制安装程序(32 位和 64 位)

步骤2:修改你的Make文件并消除其他编译器版本,类似于:

CFLAGS = -Wc,"-arch i386" -Wc,"-arch x86_64" -Wc ....
LDFLAGS = -arch i386 -arch x86_64 .....

Based on success overcoming issues surrounding MAMP and other .so modules: [Same type of error]

Step 1: Make sure your version of MAMP is Version 2 because it includes a Universal Binary installer (32-bit & 64-bit)

Step 2: Modify your Make file and eliminate the other compiler versions, similar to:

CFLAGS = -Wc,"-arch i386" -Wc,"-arch x86_64" -Wc ....
LDFLAGS = -arch i386 -arch x86_64 .....
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文