Download the PHP package extraton/php-ton-client without Composer
On this page you can find all versions of the php package extraton/php-ton-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download extraton/php-ton-client
More information about extraton/php-ton-client
Files in extraton/php-ton-client
Package php-ton-client
Short Description Extraton, PHP TON client
License Apache-2.0
Homepage https://extraton.io/
Informations about the package php-ton-client
Extraton, PHP TON Client
Extraton is a simple and powerful php-library to binding with the TON SDK. It allows to interact with FreeTON blockchain. It has the rich abilities:
- All methods of the TON SDK v1.0.0 are implemented
- Interaction with the TON SDK through an asynchronous calls
- The every method contains inline-doc
- The full autocomplete is available in a such IDE like the PHPStorm
- Simple installation by the Composer package manager
- The automatic download of the TON SDK library for the current environment
- The client auto configuration (out-of-the-box)
- Covered by the unit-tests
- Fully covered by the integration tests
- Tools to maintain code quality (static analyser and codestyle checker)
- Tools to the quick start to develop (see Makefile)
- The error handling by the general exception interface (see src/Exception)
- Using generators to iterate the asynchronous events
- You can add your own client implementation based on Binding
- A simple interface to the graphql requests
- Temporary logs creation for the detailed analysis on integration tests running
Requirements
- php7.4+ or php8.0+
- ffi extension
- json extension
- zlib extension
- TON SDK Library 1.22.0 (download script included)
Installation
To install it via Composer simply run:
To automatically download the TON SDK library add the following lines to your project composer.json
file:
The library will be downloaded after the commands or are called in your project root. To forced download the TON SDK library for your operating system, run the following command:
The TON SDK library will be installed to the directory .
Configuring
Simple TonClient instantiation:
It uses the default configuration:
You can start using a simple configuration for TonClient:
All configuration options are available here. After instantiate the TonClient will automatically detect operating system and path to the TON SDK library:
Default path: YOUR_PROJECT_ROOT/vendor/extraton/bin/tonclient.*
. Also you can specify path by the following lines of code:
Basic usage
Building queries
Use special classes to easily build queries:
You can add your own query class that implements the interface \Extraton\TonClient\Entity\Net\QueryInterface
or extends the class \Extraton\TonClient\Entity\Net\AbstractQuery
.
The following constants are available for filters and directions:
Advanced usage
Use the following example to build an application for monitoring events coming from the blockchain network:
Detailed example
Examples
Please see Integration tests for more information on detailed usage.
⚠️ Warning
We use experemental PHP extension FFI. This extension allows the loading of shared libraries, calling of C functions and accessing of C data structures in pure PHP. This is the only one possible way to async integrate with the TON SDK library.
Please read the official warnings from the developers of php:
Warning This extension is EXPERIMENTAL. The behaviour of this extension including the names of its functions and any other documentation surrounding this extension may change without notice in a future release of PHP. This extension should be used at your own risk.
Although this works, this functionality is not supported on all libffi platforms, is not efficient and leaks resources by the end of request.
We have not detected memory leaks. But sometimes we caught segmentation faults during testing. 🙏 Hopefully the FFI extension will be stabilized in future versions of php.
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
Run the following command to run unit tests:
... and integration tests:
Some tests use TON SDK methods that listen for asynchronous events. Data from these events is saved to the directory /tests/Integration/artifacts/
. This way you can analyze them in detail. For example, the test \Extraton\Tests\Integration\TonClient\ProcessingTest::testProcessMessageWithEvents
uses the call of method \Extraton\TonClient\Processing::processMessage
. Events received during generator iteration are saved in a file.
Code Quality
We use PHPStan and PHP Coding Standards Fixer to control code quality. Run the following commands to analyze the code and fix code style errors:
Contributing
Please see CONTRIBUTING for details.
Notice
If you have any issues, just feel free and open it in this repository, thx!
Credits
License
The Apache License Version 2.0. Please see License File for more information.
All versions of php-ton-client with dependencies
ext-ffi Version *
ext-json Version *
ext-zlib Version *
guzzlehttp/promises Version ^1.0