DEV Community

Cover image for Project setup (XUMM PHP SDK)
Wietse Wind
Wietse Wind

Posted on

Project setup (XUMM PHP SDK)

2. Project setup

Previous: 1. Create XUMM API credentials

The tutorial project has a little script that will use the SDK as a dependency. Right now, it returns a
Hello World response. Let's run it in our terminal:

php ./start.php   # Start server listening to port 8080 
Enter fullscreen mode Exit fullscreen mode

You should now see Hello World. Great! Any time you make changes to your project during this tutorial, you'll run the
script to see the changes.

2.1 Include the SDK

Use composer to add the XUMM PHP SDK as a dependency to your project:

composer require xrpl/xumm-sdk-php
Enter fullscreen mode Exit fullscreen mode

2.2 Add your credentials

Note: this is the only part that won't be included in the code solution of this chapter, as everybody's credentials are
unique.

Assign the credentials you created in
Step 1
to the XUMM_API_KEY and XUMM_API_SECRET environment variables (be aware you need to do this on every new terminal
session):

export XUMM_API_KEY="{your API key}"
export XUMM_API_SECRET="{your API secret}"
Enter fullscreen mode Exit fullscreen mode

2.3 Use the XUMM SDK

In start.php, include composer's autoload file at the top of the script, so that your script can find the XummSdk
class:

require_once './vendor/autoload.php';
Enter fullscreen mode Exit fullscreen mode

Now instantiate the XummSdk. It will source your credentials from the environment variables you set in step 2.2.
To test the SDK, call XummSdk::ping and show the application name.

$sdk = new \Xrpl\XummSdkPhp\XummSdk();
$pong = $sdk->ping();
echo "Application name: " . $pong->application->name
Enter fullscreen mode Exit fullscreen mode

Now when you run your script your should see:

Application name: {your app name}
Enter fullscreen mode Exit fullscreen mode

🎉 It works!

Next: 3. Your first payload

--

Credits: thank you Pauline!

Discussion (1)

Collapse
pennystringer profile image
PennyStringer

Good job .I found it to be way cheaper . View Using the XUMM PHP SDK (tutorial) Series' Articles on DEV Community. and they provides 100 % placement to their students. Does vashikaran works