没有不值得去解决的问题,也没有不值得去学习的技术!

When Running Composer Install: Fix the Missing PHP rdkafka Extension Required by enqueue/rdkafka 0.10.19

When running: composer install, it prompted: enqueue/rdkafka 0.10.19 requires ext-rdkafka -> it is missing from your system. Install or enable PHP's rdkafka extension.

1. When running: composer install, it prompted: enqueue/rdkafka 0.10.19 requires ext-rdkafka -> it is missing from your system. Install or enable PHP’s rdkafka extension. See Figure 1.

When running: composer install, it prompted: enqueue/rdkafka 0.10.19 requires ext-rdkafka -> it is missing from your system. Install or enable PHP's rdkafka extension.
Figure 1
Plaintext
PS E:\wwwroot\object> composer install
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.

  Problem 1
    - enqueue/rdkafka is locked to version 0.10.19 and an update of this package was not requested.
    - enqueue/rdkafka 0.10.19 requires ext-rdkafka ^4.0|^5.0|^6.0 -> it is missing from your system. Install or enable PHP's rdkafka extension.

To enable extensions, verify that they are enabled in your .ini files:
    - C:\php-7.4.27\php.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-rdkafka` to temporarily ignore these required extensions.

2. I decided to enable PHP’s rdkafka extension. I opened https://pecl.php.net/package/rdkafka/6.0.1/windows and downloaded 7.4 Thread Safe (TS) x64. After extracting php_rdkafka-6.0.1-7.4-ts-vc15-x64, I copied php_rdkafka.dll to: C:\php-7.4.27\ext\php_rdkafka.dll. Then I edited php.ini and added extension=rdkafka

3. When restarting PHP, an error occurred: PHP Warning: PHP Startup: Unable to load dynamic library ‘rdkafka’. See Figure 2.

When restarting PHP, an error occurred: PHP Warning: PHP Startup: Unable to load dynamic library 'rdkafka'
Figure 2
Plaintext
PS C:\Users\Lenovo> php-cgi.exe -b 127.0.0.1:9000-c C:/php-7.4.27/php.ini
PHP Warning:  PHP Startup: Unable to load dynamic library 'rdkafka' (tried: C:/php-7.4.27/ext\rdkafka (鎵句笉鍒版寚瀹氱殑妯″潡銆?, C:/php-7.4.27/ext\php_rdkafka.dll (鎵句 笉鍒版寚瀹氱殑妯″潡銷?) in Unknown on line 0
<br />
<b>Warning</b>:  PHP Startup: Unable to load dynamic library 'rdkafka' (tried: C:/php-7.4.27/ext\rdkafka (鎵句笉鍒版寚瀹氱殑妯″潡銆?, C:/php-7.4.27/ext\php_rdkafka.dll (鎵句笉鍒版寚瀹氱殑妯″潡銆?) in <b>Unknown</b> on line <b>0</b><br />
 

4. I referred to: https://arnaud.le-blanc.net/php-rdkafka-doc/phpdoc/rdkafka.installation.windows.html Installing the rdkafka extension on Windows. I placed librdkafka.dll in the PHP root directory (at the same level as php.exe), and placed the php_rdkfaka.dll file in the PHP extensions directory (default is “ext”). I copied librdkafka.dll to: C:\php-7.4.27\librdkafka.dll. When restarting PHP, the error no longer occurred.

5. I checked phpinfo and searched for: rdkafka. The PHP rdkafka extension was successfully enabled. See Figure 3.

Checked phpinfo and searched for: rdkafka, the PHP rdkafka extension was successfully enabled
Figure 3

6. When running: composer install, the prompt no longer appeared and it ran normally. See Figure 4.

When running: composer install, the prompt no longer appeared and it ran normally
Figure 4

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系