老大们 使用php8.1版本打的二进制包运行mongodb创建索引会报错

white

问题描述

相同的代码,直接运行php start.php start,是可以正常创建mongodb索引;
而当使用php8.1版本打的二进制包运行时,mongodb创建索引会报错,个人推测是二进制打包用的mongodb版本低导致,求老大们能帮忙解决下,不然这二进制打包后,要创建的mongdb索引功能都用不了了

程序代码

$indexFields = [
            'com_id',
            'logIp',
            'logDate',
            'logUrl',
        ];
        Db::schema('mongo_sdk_log')->create('sdk_log_common-test', function ($collection) use ($indexFields) {
            foreach ($indexFields as $indexField) {
                $collection->index($indexField, null, null, ['background' => true]);
            }
        });

报错信息

[2023-08-09 11:13:57] default.INFO: SQL: sdk_log_common-test.getCollectionName() Bindings: [] Time: 0 Connection: mongo_sdk_log [] []
[2023-08-09 11:13:57] default.ERROR: 127.0.0.1 GET 127.0.0.1:8787/index/json
Error: Call to undefined method MongoDB\Driver\Manager::getEncryptedFieldsMap() in phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/vendor/mongodb/mongodb/src/functions.php:140
Stack trace:
#0 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/vendor/mongodb/mongodb/src/Database.php(278): MongoDB\get_encrypted_fields_from_driver('md_open_db', 'sdk_log_common-...', Object(MongoDB\Driver\Manager))
#1 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/vendor/jenssegers/mongodb/src/Schema/Blueprint.php(259): MongoDB\Database->createCollection('sdk_log_common-...', Array)
#2 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/vendor/jenssegers/mongodb/src/Schema/Builder.php(83): Jenssegers\Mongodb\Schema\Blueprint->create(Array)
#3 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/app/controller/IndexController.php(36): Jenssegers\Mongodb\Schema\Builder->create('sdk_log_common-...', Object(Closure))
#4 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/vendor/workerman/webman-framework/src/App.php(319): app\controller\IndexController->json(Object(support\Request))
#5 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/vendor/workerman/webman-framework/src/App.php(349): Webman\App::Webman\{closure}(Object(support\Request))
#6 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/app/middleware/MaintainControl.php(33): Webman\App::Webman\{closure}(Object(support\Request))
#7 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/vendor/workerman/webman-framework/src/App.php(341): app\middleware\MaintainControl->process(Object(support\Request), Object(Closure))
#8 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/app/middleware/AccessControl.php(19): Webman\App::Webman\{closure}(Object(support\Request))
#9 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/vendor/workerman/webman-framework/src/App.php(341): app\middleware\AccessControl->process(Object(support\Request), Object(Closure))
#10 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/vendor/workerman/webman-framework/src/App.php(141): Webman\App::Webman\{closure}(Object(support\Request))
#11 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/vendor/workerman/workerman/Connection/TcpConnection.php(646): Webman\App->onMessage(Object(Workerman\Connection\TcpConnection), Object(support\Request))
#12 [internal function]: Workerman\Connection\TcpConnection->baseRead(Resource id #795, 2, Resource id #795)
#13 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/vendor/workerman/workerman/Events/Event.php(193): EventBase->loop()
#14 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/vendor/workerman/workerman/Worker.php(1635): Workerman\Events\Event->loop()
#15 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/vendor/workerman/workerman/Worker.php(1426): Workerman\Worker::forkOneWorkerForLinux(Object(Workerman\Worker))
#16 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/vendor/workerman/workerman/Worker.php(1400): Workerman\Worker::forkWorkersForLinux()
#17 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/vendor/workerman/workerman/Worker.php(560): Workerman\Worker::forkWorkers()
#18 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/vendor/workerman/webman-framework/src/support/App.php(131): Workerman\Worker::runAll()
#19 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/vendor/webman/console/src/Commands/StartCommand.php(29): support\App::run()
#20 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/vendor/symfony/console/Command/Command.php(326): Webman\Console\Commands\StartCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/vendor/symfony/console/Application.php(1063): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/vendor/symfony/console/Application.php(320): Symfony\Component\Console\Application->doRunCommand(Object(Webman\Console\Commands\StartCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/vendor/symfony/console/Application.php(174): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 phar:///mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin/webman(45): Symfony\Component\Console\Application->run()
#25 /mnt/e/phpstudy_pro/WWW/modosdk_server_new/build/webman.bin(5): require('phar:///mnt/e/p...')
#26 {main} [] []

操作系统及workerman/webman等框架组件具体版本

Workerman version:4.1.13 PHP version:8.1.19 Event-Loop:\Workerman\Events\Event

688 1 0
1个回答

walkor 打赏

https://github.com/walkor/static-php-cli
这个是源码,欢迎pr

  • white 2023-08-09

    老大,我怕是能力不够丫,自己改不动哈,跪求老大能否百忙之中抽时间早点升级下这二进制打包的mongodb拓展版本,我最近项目用webman的二进制打包 ,这个mongodb建索引不行,有点难受呢

  • walkor 2023-08-10

    重新打包试下

  • white 2023-08-11

    好的,我重新试试,感谢老大~

  • white 2023-08-11

    重新打包可以正常创建索引了,老大威武~

年代过于久远,无法发表回答
×
🔝