I'm trying to run the sample1.php class available at php client github repo that is a simple GridDB client in php, currently running it on ubuntu 22.4.1, using the command:
php sample1.php 127.0.0.1 10001 myCluster admin admin -->Person: name=diego status=true count=2 lob=ABDCS
This raises the error:
HP Fatal error: Uncaught Error: Class "StoreFactory" not found in /home/diego/Documents/php_client/sample/sample1.php:7Stack trace:#0 {main} thrown in /home/diego/Documents/php_client/sample/sample1.php on line 7
the php file is the following:
<?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"); } }?>
I have already tried to export all the global vars:
1. Write the following desctiption in /etc/php.ini. extension=<PHP client library file directory path>2. Set LD_LIBRARY_PATH. export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:<C client library file directory path>
Also checked if the server is running:
sudo systemctl status gridstore
this pritns the following:
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