Skip to content
A php library to work with the Libra gRPC client and protobuf.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Latest Stable Version License Build Status

A php library to work with the Libra gRPC client and protobuf.

Sample Code

require __DIR__ . '/../vendor/autoload.php';

use PhpLibra\LibraClient;


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


The best place to learn about the library is to read the example code.

php examples/get_account_state.php
php examples/get_balance.php

Installation with composer

composer require php-libra/php-libra

Note to Developers

  • Libra Core is a prototype and so is this library.
  • The APIs are constantly evolving and changing.

Protobuf Installation

Official gRPC documentation here

For Ubuntu LTS 18.04

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.

# Check that grpc extension is enabled
# Should show something.
php -i | grep grpc

Build protobufs for php

All *.proto files are from libra repo.

protoc -I proto --php_out=src --grpc_out=src --plugin=protoc-gen-grpc=`which grpc_php_plugin` proto/*.proto

The above command will generate php protobuf in the following folders.

  • src/Admission_control
  • src/GPBMetadata
  • src/Mempool
  • src/Types

The only code that is editable for the library resides in src/PhpLibra

The above command will auto generate php proto files to lib folder

Other Packages

A lot of ideas and inspirations for this package were taken from

Common Errors

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

You do not have the grpc library enabled. php -i | grep grpc should return something. Add to your php.ini. See above.

Class 'Grpc\ChannelCredentials' not found

Missing on your php server. Either ../fpm/php.ini or ../apache/php.ini Check phpinfo() for grpc to appear. Restart your server.


An open source library from:


You can’t perform that action at this time.