Update the PHP samples to xrpl_php 2.x - #3881
Open
AlexanderBuzz wants to merge 1 commit into
Open
Conversation
The samples were written against v0.8.5, which used the namespace `XRPL_PHP\`. The library moved to `Hardcastle\XRPL_PHP\`, so every sample fails with a class-not-found error against any current version. The install instruction in the tutorial is unpinned, so a reader following it gets 2.3.0 and none of the code runs. - Namespace corrected in the three code samples and in the inline blocks of both tutorials, 20 places in total - The composer.json of both samples moves from ^0.8.5 to ^2.3 - get-started-php.md said PHP 8.1; the library requires 8.2 since 1.0.0 and declares it as a constraint since 2.0.0, so 8.1 cannot install it. ext-bcmath was missing from the requirements as well - The comment naming the sample wallet's address did not match the seed above it All three samples were run against the Testnet with 2.3.0; send-xrp.php reaches tesSUCCESS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The XRPL_PHP library has been updated and the PHP code samples don't run with the newest version.
They use the namespace
XRPL_PHP\, but the library renamed it toHardcastle\XRPL_PHP\The samples' own
composer.jsonpins^0.8.5, so they are internallyconsistent — but Get Started Using PHP tells the reader:
composer require hardcastle/xrpl_phpThat is unpinned, so anyone following the tutorial today installs 2.3.0 and every sample fails immediately:
PHP Fatal error: Uncaught Error: Class "XRPL_PHP\Client\JsonRpcClient" not found
Changes
both tutorials — 20 places. send-xrp.md pulls most of its code in via
code-snippet, so only its three additional inline blocks needed touching.
to 0.8.5 instead would also have worked, but that release predates everything
from 1.0.0 onwards.
has required 8.2 since 1.0.0 and declares it as a constraint since 2.0.0, so
8.1 can no longer install it. ext-bcmath was missing from the list as well —
it is a direct requirement alongside GMP.
the seed above it.
Nothing else in the samples needed changing: fundWallet(), autofill(),
sign() and submitAndWait() all behave the same in 2.x.
Verification
All three samples were run against the Testnet with xrpl_php 2.3.0:
| Sample | Result |
| get-started/php/base.php | wallet created and funded |
| get-started/php/get-account-info.php | account data returned |
| send-xrp/php/send-xrp.php | tesSUCCESS |
The hardcoded example seed in send-xrp.php still has a funded Testnet account,
so that sample works as written.
Note
I maintain hardcastle/xrpl_php, so
happy to keep these samples current as the library moves. If a newer version
ever breaks them again, feel free to ping me.