Skip to content

docs(php): enhanced PHP documentation to account for ecourty/xrpl-php #3047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions @l10n/ja/docs/references/client-libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ seo:

その他のプログラミング言語の場合、[HTTP APIs](http-websocket-apis/index.md)を通してXRP Ledgerにアクセスすることが可能です。

| 言語 | ライブラリ名 | Get Started | APIリファレンス | ソースコード |
|---------------------------------|------------------------|--------------|---------------|-------------|
| **Python** | `xrpl-py` | [Pythonを使ってみよう](../tutorials/python/build-apps/get-started.md) | [API リファレンス](https://xrpl-py.readthedocs.io/) | [リポジトリ](https://github.com/XRPLF/xrpl-py) |
| **JavaScript** / **TypeScript** | `xrpl.js` | [JavaScriptを使ってみよう](../tutorials/javascript/build-apps/get-started.md) | [API リファレンス](https://js.xrpl.org/) | [リポジトリ](https://github.com/XRPLF/xrpl.js) |
| **JavaScript** / **TypeScript** | `xrpl-client` | [触ってみる](https://jsfiddle.net/WietseWind/35az6p1b/) | [NPM リファレンス](https://www.npmjs.com/package/xrpl-client) | [リポジトリ](https://github.com/XRPL-Labs/xrpl-client) |
| **JavaScript** / **TypeScript** | `xrpl-accountlib` | [触ってみる](https://jsfiddle.net/WietseWind/gkefpnu0/) | [NPM リファレンス](https://www.npmjs.com/package/xrpl-accountlib) | [リポジトリ](https://github.com/WietseWind/xrpl-accountlib) |
| **C++** | `rippled` 署名ライブラリ | [署名ライブラリを使ってみよう](https://github.com/XRPLF/rippled/tree/develop/Builds/linux#signing-library) | | ([`rippled`](https://github.com/XRPLF/rippled/))の一部 |
| **Java** | `xrpl4j` | [Javaを使ってみよう](../tutorials/java/build-apps/get-started.md) | [API リファレンス](https://javadoc.io/doc/org.xrpl/) | [リポジトリ](https://github.com/XRPLF/xrpl4j) |
| **PHP** | `XRPL_PHP` | [PHPを使ってみよう](../tutorials/php/build-apps/get-started.md) | [XRPL_PHP ドキュメント](https://alexanderbuzz.github.io/xrpl-php-docs/) | [リポジトリ](https://github.com/AlexanderBuzz/xrpl-php) |
| 言語 | ライブラリ名 | Get Started | APIリファレンス | ソースコード |
|---------------------------------|-------------------|----------------------------------------------------------------------------------------------|---------------------------------------------------------------------|--------------------------------------------------------|
| **Python** | `xrpl-py` | [Pythonを使ってみよう](../tutorials/python/build-apps/get-started.md) | [API リファレンス](https://xrpl-py.readthedocs.io/) | [リポジトリ](https://github.com/XRPLF/xrpl-py) |
| **JavaScript** / **TypeScript** | `xrpl.js` | [JavaScriptを使ってみよう](../tutorials/javascript/build-apps/get-started.md) | [API リファレンス](https://js.xrpl.org/) | [リポジトリ](https://github.com/XRPLF/xrpl.js) |
| **JavaScript** / **TypeScript** | `xrpl-client` | [触ってみる](https://jsfiddle.net/WietseWind/35az6p1b/) | [NPM リファレンス](https://www.npmjs.com/package/xrpl-client) | [リポジトリ](https://github.com/XRPL-Labs/xrpl-client) |
| **JavaScript** / **TypeScript** | `xrpl-accountlib` | [触ってみる](https://jsfiddle.net/WietseWind/gkefpnu0/) | [NPM リファレンス](https://www.npmjs.com/package/xrpl-accountlib) | [リポジトリ](https://github.com/WietseWind/xrpl-accountlib) |
| **C++** | `rippled` 署名ライブラリ | [署名ライブラリを使ってみよう](https://github.com/XRPLF/rippled/tree/develop/Builds/linux#signing-library) | | ([`rippled`](https://github.com/XRPLF/rippled/))の一部 |
| **Java** | `xrpl4j` | [Javaを使ってみよう](../tutorials/java/build-apps/get-started.md) | [API リファレンス](https://javadoc.io/doc/org.xrpl/) | [リポジトリ](https://github.com/XRPLF/xrpl4j) |
| **PHP** | `xrpl-php` | [PHPを使ってみよう](../tutorials/php/ecourty_xrpl-php/index.md) | [xrpl-php ドキュメント](https://github.com/EdouardCourty/xrpl-php#readme) | [リポジトリ](https://github.com/EdouardCourty/xrpl-php) |
| **PHP** | `XRPL_PHP` | [PHPを使ってみよう](../tutorials/php/hardcastle_xrpl_php/build-apps/get-started.md) | [XRPL_PHP ドキュメント](https://alexanderbuzz.github.io/xrpl-php-docs/) | [リポジトリ](https://github.com/AlexanderBuzz/xrpl-php) |
21 changes: 11 additions & 10 deletions docs/references/client-libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ These client libraries simplify some of the common work of accessing and process

For other programming languages, you can access the XRP Ledger through the [HTTP APIs](http-websocket-apis/index.md).

| Language | Library Name | Get Started | API Reference | Source Code |
|---------------------------------|---------------------------|-------------|--------------|-------------|
| **Python** | `xrpl-py` | [Get Started Using Python](../tutorials/python/build-apps/get-started.md) | [API Reference](https://xrpl-py.readthedocs.io/) | [Repo](https://github.com/XRPLF/xrpl-py) |
| **JavaScript** / **TypeScript** | `xrpl.js` | [Get Started](../tutorials/javascript/build-apps/get-started.md) | [API Reference](https://js.xrpl.org/) | [Repo](https://github.com/XRPLF/xrpl.js) |
| **JavaScript** / **TypeScript** | `xrpl-client` | [Get Started](https://jsfiddle.net/WietseWind/35az6p1b/) | [NPM Reference](https://www.npmjs.com/package/xrpl-client) | [Repo](https://github.com/XRPL-Labs/xrpl-client) |
| **JavaScript** / **TypeScript** | `xrpl-accountlib` | [Get Started](https://jsfiddle.net/WietseWind/gkefpnu0/) | [NPM Reference](https://www.npmjs.com/package/xrpl-accountlib) | [Repo](https://github.com/WietseWind/xrpl-accountlib) |
| **C++** | `rippled` Signing Library | [Get Started](https://github.com/XRPLF/rippled/tree/develop/Builds/linux#signing-library) | | (Part of [`rippled`](https://github.com/XRPLF/rippled/)) |
| **Java** | `xrpl4j` | [Get Started Using Java](../tutorials/java/build-apps/get-started.md) | [API Reference](https://javadoc.io/doc/org.xrpl/) | [Repo](https://github.com/XRPLF/xrpl4j) |
| **PHP** | `XRPL_PHP` | [Get Started Using PHP](../tutorials/php/build-apps/get-started.md) | [XRPL_PHP Docs](https://alexanderbuzz.github.io/xrpl-php-docs/) | [Repo](https://github.com/AlexanderBuzz/xrpl-php) |
| **Ruby** | `XRPB` | | [XRPB Docs](https://www.rubydoc.info/gems/xrbp) | [Repo](https://github.com/DevNullProd/XRBP) |
| Language | Library Name | Get Started | API Reference | Source Code |
|---------------------------------|---------------------------|----------------------------------------------------------------------------------------------|-------------------------------------------------------------------|----------------------------------------------------------|
| **Python** | `xrpl-py` | [Get Started Using Python](../tutorials/python/build-apps/get-started.md) | [API Reference](https://xrpl-py.readthedocs.io/) | [Repo](https://github.com/XRPLF/xrpl-py) |
| **JavaScript** / **TypeScript** | `xrpl.js` | [Get Started](../tutorials/javascript/build-apps/get-started.md) | [API Reference](https://js.xrpl.org/) | [Repo](https://github.com/XRPLF/xrpl.js) |
| **JavaScript** / **TypeScript** | `xrpl-client` | [Get Started](https://jsfiddle.net/WietseWind/35az6p1b/) | [NPM Reference](https://www.npmjs.com/package/xrpl-client) | [Repo](https://github.com/XRPL-Labs/xrpl-client) |
| **JavaScript** / **TypeScript** | `xrpl-accountlib` | [Get Started](https://jsfiddle.net/WietseWind/gkefpnu0/) | [NPM Reference](https://www.npmjs.com/package/xrpl-accountlib) | [Repo](https://github.com/WietseWind/xrpl-accountlib) |
| **C++** | `rippled` Signing Library | [Get Started](https://github.com/XRPLF/rippled/tree/develop/Builds/linux#signing-library) | | (Part of [`rippled`](https://github.com/XRPLF/rippled/)) |
| **Java** | `xrpl4j` | [Get Started Using Java](../tutorials/java/build-apps/get-started.md) | [API Reference](https://javadoc.io/doc/org.xrpl/) | [Repo](https://github.com/XRPLF/xrpl4j) |
| **PHP** | `xrpl-php` | [Get Started Using xrpl-php](../tutorials/php/ecourty_xrpl-php/index.md) | [xrpl-php Docs](https://github.com/EdouardCourty/xrpl-php#readme) | [Repo](https://github.com/EdouardCourty/xrpl-php) |
| **PHP** | `XRPL_PHP` | [Get Started Using XRPL_PHP](../tutorials/php/hardcastle_xrpl_php/build-apps/get-started.md) | [XRPL_PHP Docs](https://alexanderbuzz.github.io/xrpl-php-docs/) | [Repo](https://github.com/AlexanderBuzz/xrpl-php) |
| **Ruby** | `XRPB` | | [XRPB Docs](https://www.rubydoc.info/gems/xrbp) | [Repo](https://github.com/DevNullProd/XRBP) |
2 changes: 1 addition & 1 deletion docs/tutorials/how-tos/send-xrp.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ To interact with the XRP Ledger, you need to set up a dev environment with the n
- **JavaScript** with the [xrpl.js library](https://github.com/XRPLF/xrpl.js/). See [Get Started Using JavaScript](../javascript/build-apps/get-started.md) for setup steps.
- **Python** with the [`xrpl-py` library](https://xrpl-py.readthedocs.io/). See [Get Started using Python](../python/build-apps/get-started.md) for setup steps.
- **Java** with the [xrpl4j library](https://github.com/XRPLF/xrpl4j). See [Get Started Using Java](../java/build-apps/get-started.md) for setup steps.
- **PHP** with the [XRPL_PHP library](https://github.com/AlexanderBuzz/xrpl-php). See [Get Started Using PHP](../php/build-apps/get-started.md) for setup steps.
- **PHP** with the [PHP Client Libraries](/docs/tutorials/php/index.md)


## Send a Payment on the Test Net
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ These tutorials walk you through the basics of building a very simple XRP Ledger

{% xrpl-card title="Java" body="Using xrpl4j, a pure Java library." href="/docs/tutorials/java/" image="/img/logos/java.svg" imageAlt="Java logo" /%}

{% xrpl-card title="PHP" body="Using the XRPL_PHP client library." href="/docs/tutorials/php/" image="/img/logos/php.svg" imageAlt="PHP logo" /%}
{% xrpl-card title="PHP" body="Using the PHP client libraries." href="/docs/tutorials/php/" image="/img/logos/php.svg" imageAlt="PHP logo" /%}

{% xrpl-card title="HTTP & WebSocket APIs" body="Access the XRP Ledger directly through the APIs of its core server." href="/docs/tutorials/http-websocket-apis/" image="/img/logos/globe.svg" imageAlt="globe icon" /%}

Expand Down
14 changes: 0 additions & 14 deletions docs/tutorials/php/build-apps/index.md

This file was deleted.

27 changes: 27 additions & 0 deletions docs/tutorials/php/ecourty_xrpl-php/build-apps/create-a-wallet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Create a wallet

Creating an XRP Wallet is the base operation when building applications that interact with the XRP Ledger.

If you want to import a wallet from an existing seed, refer to the [Import a Wallet](./import-a-wallet.md) tutorial.

Wallets can be generated using two different algorithms:
- ED25519
- SECP256K1

The XRPL-PHP library supports both algorithms. By default, the `ED25519` algorithm is used.

_If you're interested in discovering how the generation workflows work, refer to the [ED25519 Key Derivation](/docs/concepts/accounts/cryptographic-keys.md#ed25519-key-derivation) or [SECP256K1 Key Dreivation](/docs/concepts/accounts/cryptographic-keys.md#secp256k1-key-derivation) documentation page_.

<br />

```php
<?php

use XRPL\Enum\Algorithm;
use XRPL\ValueObject\Wallet;

$ed25519Wallet = Wallet::generate(Algorithm::ED25519);
$secp256k1Wallet = Wallet::generate(Algorithm::SECP256K1);

// Using Wallet::generate(); will use the ED25519 algorithm by default.
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
seo:
description: Fund a test wallet on the XRP Ledger using the ecourty/xrpl-php library.
---

# Fund a test wallet

Funding a test wallet is a simple process.
You can use the XRPL PHP library to generate a new wallet and request funds from the XRP Testnet Faucet.

```php
<?php

use XRPL\Enum\Network;
use XRPL\Service\Faucet;
use XRPL\ValueObject\Wallet;

$wallet = Wallet::generate(); // Or Wallet::generateFromSeed('...');
Faucet::addFunds($wallet); // Will add 100 XRP to the Account associated to this wallet

// By default, the Faucet class will fund the wallet on the testnet.
// If you want to fund the wallet on the devnet, you can pass a second argument to the ::addFunds method:
Faucet::addFunds($wallet, Network::DEVNET);

// The Wallet::fundWallet facade method can also be used
$wallet = Wallet::generate();
$wallet->addFunds();
```

{% admonition type="warning" name="Rate limiting" %}
Sending too many requests will trigger the Faucet's rate limit.
Re-import an already funded wallet instead of creating a new random one every time you run your test scripts.
{% /admonition %}

The funded wallets can then be used to submit transactions to the XRP Ledger.
24 changes: 24 additions & 0 deletions docs/tutorials/php/ecourty_xrpl-php/build-apps/import-a-wallet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Import a wallet

Importing an existing wallet is a common operation when building applications that interact with the XRP Ledger.

All you need is your wallet seed. It should look like this:
- **ED25519**: `sEdSgVhT1uGZErffGfLHX61ZkjAtPg2` (31 long)
- **SECP256K1**: `ssPjp8iEJug1fFzksyMTQcJKe944V` (29 long)

Then, simply import your wallet using either the `Wallet::generateFromSeed` facade method, or the `WalletGenerator::generateFromSeed` method.

```php
<?php

use XRPL\Service\Wallet\WalletGenerator;
use XRPL\ValueObject\Wallet;

$seed = 'sEdSgVhT1uGZErffGfLHX61ZkjAtPg2';

// 1. Using the Wallet class
$importedWallet = Wallet::generateFromSeed($seed);

// 2. Using the WalletGenerator class
$importedWallet = WalletGenerator::generateFromSeed($seed);
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Submit Transactions

Submitting transactions to the XRP Ledger using the `ecourty/xrpl-php` library is a straightforward process.

This tutorial will guide you through the steps to create, sign, and submit a transaction to the XRP Ledger.
All you need is a `Wallet` instance, or your own Wallet class implementing `WalletInterface`.

{% admonition type="info" name="Mandatory Transaction Fields" %}
Every transaction need to contain a `TransactionType` field, which defines the type of transaction you want to submit.
Refer to the [Transaction Types documentation](/docs/references/protocol/transactions/types/index.md) for more information.
{% /admonition %}

```php
<?php

use XRPL\Client\XRPLClient;
use XRPL\ValueObject\Wallet;

$wallet = Wallet::generateFromSeed('...'); // Replace '...' with your seed

$transactionPayload = [
'TransactionType' => 'Payment',
'Account' => $wallet->getAddress(),
'Destination' => 'rPEPPER7kfTD9w2To4CQk6UCfuHM9c6GDY',
'Amount' => '1000000',
];

$client = new XRPLClient('https://s.altnet.rippletest.net:51234');

$result = $client->submitSingleSignTransaction($transactionPayload, $wallet);
```

Every field will then be converted into its own [Internal Format](/docs/references/protocol/binary-format.md#internal-format) before being submitted to the XRP Ledger Node.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
seo:
description: Mint an NFT on the XRP Ledger using the ecourty/xrpl-php library.
---

# Mint an NFT

Minting an NFT on the XRP Ledger is an easy process.
You need to craft your transaction payload with care to avoid any errors:
- Define the flags according to the NFT type you want to mint. [Documentation reference](/docs/references/protocol/transactions/types/nftokenmint#nftokenmint-flags)
- Define the "content" or your NFT in the `URI` field, this is usually an IPFS link to the NFT metadata.
- Craft the transaction!

_Here is the [list of all the available fields on the `NFTokenMint` transaction](/docs/references/protocol/transactions/types/nftokenmint.md)_

<br />

Here is a tutorial on how to mint a simple NFT on the testnet, using a random wallet.
```php
<?php

use XRPL\Client\XRPLClient;
use XRPL\Service\Faucet;
use XRPL\ValueObject\Wallet;

$wallet = Wallet::generate();
Faucet::addFunds($wallet);

echo 'Wallet generated and funded!' . \PHP_EOL;

$client = new XRPLClient('https://s.altnet.rippletest.net:51234');

$transactionData = [
'TransactionType' => 'NFTokenMint',
'Account' => $wallet->getAddress(),
'URI' => '11223344', // Can be virtually anything (Needs to be a hex-encoded)
'Flags' => 8, // Makes the NFT transferable
'TransferFee' => 1000, // Fee for transferring the NFT
'NFTokenTaxon' => 0, // Allows for grouping of NFTs (e.g. by collection, use the same taxon for NFTs of the same collection)
];

$transactionResult = $client->submitSingleSignTransaction($transactionData, $wallet);

echo 'NFT minted!' . \PHP_EOL;
```

Easy, right?
You can then retrieve the transaction hash from the `$transactionResult` object to track the transaction on the XRP Ledger.

More examples can be found in the [ecourty/xrpl-php GitHub repository](https://github.com/EdouardCourty/xrpl-php)
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
seo:
description: Send a payment on the XRP Ledger using the ecourty/xrpl-php library.
---

# Send a Payment

Payment are the most executed transactions on the XRP Ledger!
All you need is a funded Wallet and a destination address.

<br />

```php
<?php

use XRPL\Client\XRPLClient;
use XRPL\ValueObject\Wallet;

$wallet = Wallet::generate();
Faucet::addFunds($wallet);

$client = new XRPLClient('https://s.altnet.rippletest.net:51234'); // Public Testnet Ripple Node

$transactionData = [
'TransactionType' => 'Payment',
'Account' => $wallet->getAddress(),
'Destination' => $receiverWallet->getAddress(),
'Amount' => XRPConverter::xrpToDrops(25), // 25 XRP
];

$client->submitSingleSignTransaction($transactionData, $originWallet);
```

You can then retrieve the transaction hash from the `$transactionResult` object to track the transaction on the XRP Ledger.

More examples can be found in the [ecourty/xrpl-php GitHub repository](https://github.com/EdouardCourty/xrpl-php)
Loading