Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

0xcregis/cregis-sdk-php

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Cregis SDK User Guide

I. Prerequisites

  • PHP version ≥ 7.0
  • Composer installed (dependency management tool)
  • Project .env file configured

II. SDK Installation

Install the SDK to your project via Composer:

composer require cregis/cregis-sdk-php:^2.0

After installation, Composer will automatically handle dependencies and generate vendor/autoload.php, and the framework will automatically load the SDK libraries.


III. Framework Integration Guide

Add the following content to the .env file in the root directory

## production or development environment
ENVIRONMENT=production
# API base URL (default value can be modified as needed)
API_BASE_URI=https://t-xxxxxxx.cregis.io
# API key
API_KEY=16d4xxxxxxxxxxxxxxxxxxbd7895f4d
# Project ID
PID=1418xxxxxxxxxxx89664

Add references where needed

use Cregis\Services\PayoutService;
use Cregis\Services\DepositService;
use Cregis\Services\CallbackService;

Example of creating an address, other examples can be found in demo.php in the SDK

    public function createAddress()
    {
            $depositService = new DepositService();
            try {
                $result = $depositService->createAddress([
                    "callback_url"=> "http://xxxx.com/deposit/callback",
                    "chain_id"=> "60",
                    "alias"=> "cc",
                ]);
                echo "createAddress: " . json_encode($result, JSON_UNESCAPED_UNICODE) . "\n";
            } catch (\Exception $e) {
                echo "createAddress-error:" . $e->getMessage() . "\n";
            }
        return 'hello,' ;
    }

IV. Notes

  • Ensure that the framework's vendor/autoload.php is correctly loaded (already handled by mainstream frameworks by default).
  • For production environments, set ENVIRONMENT to production in the .env file to avoid using test environment interfaces.
  • If the framework does not automatically load the .env file (e.g., ThinkPHP), you need to manually call Dotenv\Dotenv::createImmutable(__DIR__)->load(); to load the configuration.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.