Thrift requires PHP 8.2 Thrift makes as few assumptions about your PHP environment as possible while trying to make some more advanced PHP features (i.e. APCu cacheing using asbolute path URLs) as simple as possible.
To use Thrift in your PHP codebase, take the following steps:
After that, you have to manually include the Thrift package created by the compiler:
require_once 'packages/Service/Service.php';
require_once 'packages/Service/Types.php';
PHP_INT_SIZE
This built-in signals whether your architecture is 32 or 64 bit and is
used by the TBinaryProtocol to properly use pack() and unpack() to
serialize data.
apcu_fetch(), apcu_store()
APCu cache is used by the TSocketPool class. If you do not have APCu installed,
Thrift will fill in null stub function definitions.
TJSONProtocol now holds a string, binary or numeric value to the same maximum string size as TBinaryProtocol and TCompactProtocol, and reports a longer one with a TProtocolException of type SIZE_LIMIT. A JSON value carries no length in front of it, so the maximum applies to the bytes it takes on the wire while it is read. The maximum defaults to TProtocol::DEFAULT_MAX_STRING_SIZE, 16384000 bytes; it is an optional constructor argument of TJSONProtocol and of TJSONProtocolFactory; pass 0 to read values of any length, as before.
TCurlClient follows a redirect only within the origin of the URL it is configured with, that is to the same scheme, host and port. It sends the request again there, with its headers and body, and follows at most one redirect, as before. A redirect to another origin, including one from http to https, now fails the request with a TTransportException, as any redirect does with THttpClient. Configure the client with the scheme, host and port that serve the requests.
TBinaryProtocol, TBinaryProtocolAccelerated and TCompactProtocol now refuse a string or binary field longer than their maximum string size before reading it, with a TProtocolException of type SIZE_LIMIT. The maximum defaults to TProtocol::DEFAULT_MAX_STRING_SIZE, 16384000 bytes, the frame size limit the framed transports apply. It is an optional constructor argument of the three protocols and of their factories; pass 0 to read strings of any length, as before.
The legacy callable/string $debugHandler argument has been removed from TSocket, TSSLSocket and TSocketPool. The constructors now accept a PSR-3 logger via the $logger parameter instead. TSocket::setDebug(), TSocket::DEFAULT_DEBUG_HANDLER and TSSLServerSocket::getSSLHost() have also been removed. The ssl:// prefix is still applied automatically by TSSLServerSocket and TSSLSocket. Additionally, TSocket::open() no longer falls back to the send timeout for the connect step; use TSocket::setConnectTimeout() to configure a dedicated connect timeout. The default connect timeout is now 1 second.
PSR-4 loader is now the default. If you want to use class maps instead, use -gen php:classmap.
If using PSR-4, use $thriftClassLoader->registerNamespace('namespace', '<path>') instead of $thriftClassLoader->registerDefinition('namespace', '<path>').