Introducing the new Aerospike PHP 7 client (we've moved the PHP 5 client)

Dear Aerospike Users,

We’d like to introduce our new Aerospike client for PHP 7. This client supports PHP versions >= 7.

To access this client, read about the differences from the previous Aerospike PHP Client, and read about the documentation and dependencies, go to this repo.

The legacy Aerospike PHP 5 client has been moved to this repo. This client supports PHP versions 5.3.3+, 5.4, 5.5, and 5.6.

If you have any questions, please let us know.

Hey guys, (@Mnemaudsyne / @rbotzer) couple of things I wanted to mention…

Firstly, moving the old code to a different repo and keeping this one for new code (7+) wasn’t really the best idea, it forced us to create application updates on deployments where composer was unable to load Aerospike from the cache as the repo no longer existed - bit of a no no really, the new code (for upgraders) should have been moved to the new repo, and legacy code left to die as it were.

Anyhoo, that aside, I’m also wondering why the const values for things like Aerospike::OK etc have been commented out? This comes in really handy when building apps using Aerospike in the IDE where’s now all I see are yellow warnings all over my code as it can’t find the constant values - the code still runs of course, but just makes it messy and developing using new options etc requires me to go the the aerospike class and find those values? Bit of a step backwards for me - shame :confused:

Thanks for releasing support though, just could have been smoother - I’ll post those comments in the GitHub repo

Thanks for the feedback.

I’m cleaning up and expanding stub PHPDoc code in the repo. On our end it’ll be used to generate web pages in our API docs.

No problem, thanks @rbotzer

Adding a note that the API documentation is now hosted on our site at https://www.aerospike.com/apidocs/php/

Within the client repo itself there is a PHP stub under docs/phpdoc. You can import the stub into your IDE for auto-completion, or build the API documentation using phpDocumentor

phpdoc run -v -d phpdoc/ -t html/

I am being asked to run the php5 and php7 libraries along-side one another (2 different php-fpm pools). I am guessing looking at the changes listed here: GitHub - aerospike-community/aerospike-client-php: Aerospike client for PHP7 that this may not be a good idea - or at a minimum will require some extra precautions.

For example, will sessions work the same across php5 and php7 pools with the same session key? Also, so far I have been storing stuff only in php5 using new \Aerospike\Bytes - but seeing that AS_BYTES_PHP is now AS_BYTES_BLOB in php7 - I am guessing its possible that the same value written in php5 may not be readable in php7 without extra steps (and vice versa).

Or maybe it will all “just work” - anyways, if anyone knows of specific gotchas in this scenario, any heads-up is appreciated.

Michael

The session handler stores the PHP session_serialized representation of the session object, and then decodes it using the php session deserializer. If there are no changes in these formats, the session handler should be consistent between the old and new client.

If you have been saving things directly with Aerospike\Bytes with the PHP5 Client, there may be some issues with retrieving the new value from the PHP7 Client. Basically with the PHP5 Client, when a \Aerospike\Bytes was stored, it was stored as a PHP Serialized version of the object. Along with the type AS_BYTES_PHP.

When it was retrieved this representation was deserialized back into a \Aerospike\Bytes object.

With the PHP7 Client, this deserialization should occur whenever some bytes stored as AS_BYTES_PHP are retrieved. So it is possible that the deserialization will still work. But this depends upon the deserialization algorithm and the serialization format of the \Aerospike\Bytes class not having changed between PHP 5 and PHP 7.

The PHP7 Client also converts objects stored as AS_BYTES_BLOB into \Aerospike\Bytes. But does this by calling the constructor for that Class instead of deserializing.

I would suggest running some simple tests to see what happens. e.g.:

// From the PHP5 Client
$key = $client->initKey("test", "demo", 1);
$bytes = new Aerospike\Bytes("1234");
$client->put($key, ["bytes" => $bytes]);

Then from the PHP7 Client

// From the PHP7 Client
$key = $client->initKey("test", "demo", 1);

$client->get($key, $record);

var_dump($record);

$ret_bytes = $record["bins"]["bytes"];

var_dump($ret_bytes);
var_dump($ret_bytes->s);