PHP code example of php-libra / php-libra

1. Go to this page and download the library: Download php-libra/php-libra library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

php-libra / php-libra example snippets




use PhpLibra\LibraClient;

main();

// Get the latest version
function main()
{
    $client = new LibraClient();
    echo $client->getLatestVersionNumber() . PHP_EOL;
}

php examples/get_account_state.php
php examples/get_balance.php
bash
composer 
bash
sudo apt-get install php php-dev php-pear phpunit composer protobuf-compiler-grpc libz-dev

# Install pecl
sudo pecl install grpc

# To get your current php version
php -v

# Enable gRPC extension. Example is php 7.2
sudo vi /etc/php/7.2/cli/php.ini
# for php-fpm
sudo vi /etc/php/7.2/fpm/php.ini
# for apache
sudo vi /etc/php/7.2/apache/php.ini

# Add at the end of the file and restart your services.
extension=grpc.so

# Check that grpc extension is enabled
# Should show something.
php -i | grep grpc
bash
protoc -I proto --php_out=src --grpc_out=src --plugin=protoc-gen-grpc=`which grpc_php_plugin` proto/*.proto

PHP Fatal error:  Uncaught Error: Class 'Grpc\ChannelCredentials' not found in ../code/php-libra/examples/update_to_latest.php:10