Download the PHP package l2iterative/bonsai-sdk-php without Composer

On this page you can find all versions of the php package l2iterative/bonsai-sdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package bonsai-sdk-php

PHP SDK for Bonsai API

The current Bonsai API implementation is written in Rust. Since Bonsai requires an API key and would consume the quotas to generate the zero-knowledge proof, web3 applications built with Bonsai would need a backend.

Like most web3 applications, the backend can be minimalistic, because most of the on-chain interactions can be completed through, for example, Metamask's Ethereum provider API, in the frontend.

How would the backend look like?

For the aforementioned reasons, backends often fall into the following six classes:

Numerous factors will affect which one to go:

It is important to know that this backend is going to be minimalistic. We have the backend because the API key cannot be exposed to the client. The backend may just consist of:

How to use

The documentation can be found in the docs folder. It is designed to resemble the Bonsai Rust API here:

https://github.com/risc0/risc0/blob/main/bonsai/sdk/src/alpha.rs

The integration tests can be served as tutorials. It can be as simple as follows:

Serializer

Another challenge when using a different programming language to interact with RISC Zero is about the types. This issue is particularly significant to PHP because PHP does not have separate types for different word sizes.

For example, in PHP, we have int representing integers, nothing else. But this can correspond to i8, i16, i32, i64, u8, u16, u32, u64 in Rust. There are also numbers that PHP cannot easily represent, such as i128 and u128.

Since the Rust type is the missing information here, there is no choice other than letting the developer explicitly provide the Rust type. To do so, the developer is asked to wrap all elements.

Below is a very comprehensive example that can served as a tutorial.

The corresponding Rust struct is defined as follows.

Note that we focus on String here in Rust rather than a binary string because the current serializer does have the trouble to process Vec<u8> in a different manner. If one's Rust code has to use Vec<u8> and cannot afford a wrapper, then the best solution so far is to let PHP break the string down to an array of bytes, through str_split($str).


All versions of bonsai-sdk-php with dependencies

PHP Build Version
Package Version
Requires guzzlehttp/guzzle Version ^7.8
php-64bit Version >=8.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package l2iterative/bonsai-sdk-php contains the following files

Loading the files please wait ....