You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 22.04运行GridDB PHP示例时遇StoreFactory类未找到错误

解决GridDB PHP客户端运行sample1.php时"StoreFactory类未找到"错误

我在Ubuntu 22.04.1系统上运行GridDB PHP客户端仓库中的sample1.php示例,执行命令:

php sample1.php 127.0.0.1 10001 myCluster admin admin

触发以下致命错误:

PHP Fatal error:  Uncaught Error: Class "StoreFactory" not found in /home/diego/Documents/php_client/sample/sample1.php:7
Stack trace:
#0 {main}
  thrown in /home/diego/Documents/php_client/sample/sample1.php on line 7

sample1.php代码如下:

<?php    
    if (file_exists('griddb_php_client.php')) {
        // File php wrapper is generated with SWIG 4.0.2 and below
        include_once('griddb_php_client.php');
    }

    $factory = StoreFactory::getInstance();

    $blob = pack('C*', 65, 66, 67, 68, 69, 70, 71, 72, 73, 74);
    $update = true;

    try {
        // Get GridStore object
        $gridstore = $factory->getStore(["host" => $argv[1],
                        "port" => (int)$argv[2],
                        "clusterName" => $argv[3],
                        "username" => $argv[4],
                        "password" => $argv[5]]);

        // Create a collection container
        $conInfo = new ContainerInfo(["name" => "col01",
                                   "columnInfoArray" => [["name", Type::STRING],
                                                        ["status", Type::BOOL],
                                                        ["count", Type::LONG],
                                                        ["lob", Type::BLOB]],
                                   "type" => ContainerType::COLLECTION,
                                   "rowKey" => true]);
        $gridstore->dropContainer("col01");
        $col = $gridstore->putContainer($conInfo);

        // Change auto commit mode to false
        $col->setAutoCommit(false);

        // Set an index on the Row-key Column
        $col->createIndex("name");

        // Set an index on the Column
        $col->createIndex("count");

        // Put row: RowKey is "name01"
        $ret = $col->put(["name01", false, 1, $blob]);
        // Remove row with RowKey "name01"
        $col->remove("name01");

        // Put row: RowKey is "name02"
        $col->put(["name02", false, 1, $blob]);
        $col-> commit();

        $mArray = $col->get("name02");

        // Create normal query
        $query = $col->query("select * where name = 'name02'");

        // Execute query
        $rs = $query->fetch($update);
        while ($rs->hasNext()) {
            $data = $rs->next();
            $data[2] = $data[2] + 1;
            echo("Person: name=$data[0] status=".($data[1] ? "true" : "false")
                    ." count=$data[2] lob=$data[3]\n");

            // Update row
            $rs->update($data);
        }

        // End transction
        $col->commit();
        echo("success!\n");
    } catch (GSException $e) {
        for ($i= 0; $i < $e->getErrorStackSize(); $i++) {
            echo("\n[$i]\n");
            echo($e->getErrorCode($i)."\n");
            echo($e->getLocation($i)."\n");
            echo($e->getErrorMessage($i)."\n");
        }
    }
?>

我已尝试以下操作:

  • 在/etc/php.ini中添加配置:
    extension=<PHP client library file directory path>
    
  • 设置环境变量:
    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:<C client library file directory path>
    

已确认GridDB服务处于运行状态,执行sudo systemctl status gridstore返回:

gridstore.service - GridDB database server.
     Loaded: loaded (/lib/systemd/system/gridstore.service; enabled; vendor pre>
     Active: active (running) since Sun 2023-07-09 11:09:33 -03; 38min ago
   Main PID: 1179 (gsserver)
      Tasks: 34 (limit: 2184)
     Memory: 65.6M
        CPU: 9.944s
     CGroup: /system.slice/gridstore.service
             └─1179 /usr/bin/gsserver --conf /var/lib/gridstore/conf

寻求解决该类未找到错误的方法。

内容的提问来源于stack exchange,提问作者diegao15

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 21:40:21