Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Php Thrift Laravel Package

leric/php-thrift

Apache Thrift PHP library for building cross-language RPC clients and servers. Includes generated PHP types, TBinaryProtocol serialization, PSR-4 class loading, and optional APCu caching for sockets. Requires PHP 5+.

View on GitHub
Deep Wiki
Context7

thrift php api composer package

Frequently asked questions about Php Thrift
What is leric/php-thrift used for in a Laravel application?
It provides the Apache Thrift PHP runtime for building cross-language RPC clients and servers, including generated PHP types, TBinaryProtocol serialization, PSR-4 class loading, and optional APCu socket caching. In Laravel, it only makes sense when you already have a Thrift IDL contract or must interoperate with an existing Thrift service. It is not a Laravel-native module and does not add REST, queue, or Eloquent integration.
How do I install leric/php-thrift with Composer in Laravel?
You can add it with composer require leric/php-thrift, but the upstream README describes copying thrift/lib/php/lib and using manual require_once calls for generated classes. In Laravel, isolate it behind a client wrapper and verify autoloading early. Treat Composer installation as only the first step, not a complete Laravel integration.
Is leric/php-thrift compatible with Laravel 10 and 11?
There is no published compatibility matrix for Laravel 10 or 11, and the README still says PHP 5+. The package appears to be a thin repackaging of Apache Thrift's PHP runtime, so PHP 8.x and Laravel 10/11 support is unproven. Run a proof of concept on your target PHP and Laravel versions before adopting it.
Does this package include a Laravel service provider or facade?
No. The package does not ship a Laravel service provider, config file, facade, or queue integration. You must bind your own client class in a service provider and keep generated Thrift classes out of controllers and domain code.
How do I generate PHP classes from a Thrift IDL file?
Use the Apache Thrift compiler with the php generator, for example thrift --gen php your_service.thrift. The README notes PSR-4 is the default loader in 0.12.0, so generated namespaces should be registered with the Thrift class loader or your Laravel autoloader. Commit generated code or build it in CI, and pin the compiler version to avoid runtime skew.
How do I configure TBinaryProtocol and TSocket in Laravel?
Create a TSocket with host and port, wrap it in a TBufferedTransport if needed, then use TBinaryProtocol for serialization. In Laravel, put those settings in config/thrift.php and build the client in a dedicated service class. Expose timeouts, retries, and transport options through config instead of hard-coding them in controllers.
Can I use APCu caching with Thrift sockets in Laravel?
TSocketPool can use apcu_fetch and apcu_store for socket caching when APCu is installed. If APCu is missing, the library provides null stub functions, so caching is effectively disabled. Enable APCu only after confirming it is available in your PHP-FPM or CLI runtime and that cache behavior is safe for your deployment model.
How should I test a Thrift client in a Laravel test suite?
Write contract tests against a running Thrift service or a recorded fixture, because binary protocol behavior is hard to mock meaningfully. Keep generated Thrift classes in a separate namespace and test your adapter, not the generated types. Add CI checks for PHP version, Thrift compiler version, and autoload coexistence.
What are the production risks of using leric/php-thrift?
Main risks include version skew between the Thrift compiler, generated PHP code, and runtime library, plus unproven PHP 8.x and Laravel 10/11 compatibility. Binary deserialization and RPC endpoints need security review, and the package has weak adoption signals such as low stars and zero dependents. If Thrift is not externally mandated, prefer REST/JSON, gRPC, or a maintained Apache Thrift package.
Are there maintained alternatives to leric/php-thrift for Laravel?
If you control both ends, prefer REST/JSON or gRPC for Laravel services. If you must use Thrift, evaluate the official Apache Thrift PHP runtime or an actively maintained community package instead of a thin repackaging. Isolate any choice behind an adapter so you can migrate transports later.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
rlacerda83/query-parser
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode