amashukov/toncenter-client-php
HttpClient (Guzzle-based) and Symfony HttpClient already support. No architectural friction exists for integration.HttpClient or third-party PSR-18 clients (e.g., GuzzleHttp\Client) to be used without modification.TonMasterchainInfo, TonTransaction) align well with Laravel’s DTO/Collection patterns, reducing manual parsing and validation overhead.run-get-method stack decoding, bigint handling) behind a clean API, abstracting blockchain complexity from business logic.HttpClient can replace the example’s CurlClient + middleware pipeline with built-in retry and header injection (via withOptions() or middleware).Psr17Factory or Symfony\Component\HttpFoundation.ToncenterWalletRpc adapter bridges seamlessly with Laravel services needing WalletRpcInterface (e.g., wallet management modules).ext-gmp: PHP’s GMP extension is required for bigint decoding. Laravel deployments must ensure this extension is enabled (common in most PHP stacks but may need explicit configuration in Docker/Cloud environments).542/429 retries and {ok, result} envelopes is abstracted, but custom error handling (e.g., rate-limiting logic) may require middleware tweaks.HttpClient may have subtle differences in middleware handling (e.g., retry logic). Testing with the package’s retry middleware is recommended.where('balance', '>', '1000000000')).retry() helper) replace the package’s RetryMiddleware, or keep the package’s retry logic for consistency?X-Api-Key be managed? Laravel’s config + environment variables or a dedicated service provider?TonRpcException map to Laravel’s HttpException or a custom exception class for consistency with existing error handling?retryAfter()) be layered in?Mockery or Laravel’s HttpClient mocks)?CurlClient + middleware with Laravel’s HttpClient (Guzzle-based) and its middleware stack:
use Illuminate\Support\Facades\Http;
use Amashukov\Toncenter\ToncenterClient;
$http = Http::withOptions([
'headers' => ['X-Api-Key' => config('toncenter.api_key')],
])->retry(3, 100, function ($retries, $response) {
return $response->status() === 429 || $response->status() === 542;
});
$client = new ToncenterClient($http, new \Nyholm\Psr7\Factory\Psr17Factory(), new \Nyholm\Psr7\Factory\Psr17Factory());
Symfony\Contracts\HttpClient\HttpClient can be injected directly.ToncenterWalletRpc adapter can be registered as a Laravel service binding:
$this->app->bind(\Amashukov\TonWallet\WalletRpcInterface::class, function ($app) {
return new \Amashukov\Toncenter\ToncenterWalletRpc($app->make(ToncenterClient::class));
});
getBalance) with the package’s client in a feature branch.TonAccountInfo) integrate with Laravel’s DTO/Collection patterns.ToncenterWalletRpc.Cache::remember) for frequent calls like getMasterchainInfo.HttpClient for consistency.ext-gmp in PHP configuration.X-Api-Key in Laravel’s .env.ToncenterClient as a Laravel service provider or use the container directly.getBalance, getMasterchainInfo).sendBoc).Mockery or Laravel’s HttpClient mocks).542/429 responses.{ok, result} unwrapping minimizes future envelope-handling bugs.amashukov/toncenter-client-php for breaking changes (low risk due to MIT license and active CI).Log::debug) to track retries, failed requests, or unexpected {ok, false} responses.TonRpcException provides clear error context (e.g., TonRpcException::INVALID_ENVELOPE).542/429 occurrences).getMasterchainInfo).events or a queue worker to log slow transactions.X-Api-Key) can be managed via Laravel’s ThrottleRequests middleware.X-Api-Key) may require Laravel’s queue workers for high-throughput operations.getMasterchainInfo and getBalance results in Laravel’s cache (e.g., Redis) with short TTLs (e.g., 5 minutes).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Toncenter API downtime | All TON operations fail |
How can I help you explore Laravel packages today?