简体   繁体   English

PHP 8 - 附魔不起作用 - 代理返回一个空数组

[英]PHP 8 - Enchant not working - Broker returns an empty array

I am using PHP 8 on Xampp (Windows)我在 Xampp (Windows) 上使用PHP 8

Have added extension=php_enchant.dll to php.ini已将extension=php_enchant.dll添加到php.ini

php_info

  • php directory added to windows PATH php 目录添加到 windows 路径
  • copied libenchant_hunspell.dll / libenchant_ispell.dll / libenchant_myspell.dll to [php]/lib/enchant复制libenchant_hunspell.dll / libenchant_ispell.dll / libenchant_myspell.dll[php]/lib/enchant
  • moved *.dic & *.aff to [php]/share/myspell/dicts*.dic*.aff移至[php]/share/myspell/dicts

But still cannot get Enchant to detect Brokers但仍然无法让Enchant检测到 Brokers

sample code示例代码

<?php
$broker = enchant_broker_init();
$tag = 'en_US';

$bprovides = enchant_broker_describe($broker);
echo "Current broker provides the following backend(s):\n";
print_r($bprovides);

Output Output

Current broker provides the following backend(s): Array ( ) Current broker provides the following dictionaries: Array ( )

I ran into the same problem.我遇到了同样的问题。 I am moderately skilled in the PHP core and after a few days of debugging this I finally got it to work.我对 PHP 内核有一定的熟练度,经过几天的调试,我终于让它工作了。 Unfortunately, there seem to be quite a few changes in both lib_enchant and in PHP 8.不幸的是,lib_enchant 和 PHP 8 中似乎都有很多变化。

lib_enchant 2.x and PHP 8 (on Windows) seem to only support the hunspell provider (PHP 7.x and previous was using both ispell and myspell providers). lib_enchant 2.x 和 PHP 8(在 Windows 上)似乎只支持 hunspell 提供程序(PHP 7.x 和以前的版本同时使用 ispell 和 myspell 提供程序)。 Further, it seems that enchant now hard codes the path to the provider DLLs to:此外,现在 enchant 似乎将提供程序 DLL 的路径硬编码为:

C:\usr\local\lib\enchant-2

So, you must locate libenchant2_hunspell.dll which is in the PHP distro in the lib/enchant folder to:因此,您必须在 lib/enchant 文件夹的 PHP 发行版中找到 libenchant2_hunspell.dll 以:

C:\usr\local\lib\enchant-2\libenchant2_hunspell.dll

Similarly the location of the dictionary files defaults to:同样,字典文件的位置默认为:

C:\usr\local\share\enchant

So in my case I ended up with the following files in that folder:因此,就我而言,我最终在该文件夹中找到了以下文件:

C:\usr\local\share\enchant\en_US.aff
C:\usr\local\share\enchant\en_US.dic
C:\usr\local\share\enchant\es_ANY.aff
C:\usr\local\share\enchant\es_ANY.dic

In my review of the sources for enchant it seems you might be able to control the location of the spell check dictionaries via the environment variable ENCHANT_CONFIG_DIR but I believe the provider location is now hard coded.在我对附魔来源的审查中,您似乎可以通过环境变量ENCHANT_CONFIG_DIR控制拼写检查字典的位置,但我相信提供程序位置现在是硬编码的。 This is new with lib_enchant 2.x and PHP 8... and a huge hassle for us because we do not want to install software in c:\usr\local on a Windows machine.这是 lib_enchant 2.x 和 PHP 8 的新功能......对我们来说是一个巨大的麻烦,因为我们不想在 ZAEA23489CE3AACD9B6406EBB28E0Z 机器上的 c:\usr\local 中安装软件。

I will probably work up a patch and submit it to PHP to fix this but I am concerned they will not accept it because the patch will really be in lib_enchant.我可能会制作一个补丁并将其提交给 PHP 来解决这个问题,但我担心他们不会接受它,因为补丁真的在 lib_enchant 中。 PHP does host their own copy of lib_enchant on github for building dependencies like this so perhaps they will integrate the changes. PHP 确实在 github 上托管了他们自己的 lib_enchant 副本,用于构建这样的依赖项,因此他们可能会集成更改。

I hope this helps others.我希望这对其他人有帮助。

I have no enauf reputation to leave comment for jriffel73 answer so I create a new answer.我没有任何声誉可以为jriffel73答案发表评论,因此我创建了一个新答案。

I too faced with the problem that dictionaries array is empty after all manipulations in jriffel73 answer.jriffel73答案中的所有操作之后,我也面临字典数组为空的问题。 So I just changed path for dictionaries a little bit and it worked.所以我只是稍微改变了字典的路径,它就奏效了。
From:从:

C:\usr\local\share\enchant\en_US.aff

To:至:

C:\usr\local\share\enchant\hunspell\en_US.aff

I also granted all rights to these files我还授予了这些文件的所有权利

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

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