chendujin / bitcoin
bitcoin is a plugin for a unified Bitcoin digital currency open API interface
Requires
- php: >=7.0.0
- guzzlehttp/guzzle: ~5.3|~6.2
Requires (Dev)
- phpunit/phpunit: ~5.7
This package is auto-updated.
Last update: 2024-10-26 04:16:01 UTC
README
Bitcoin Package for Laravel
Introduction
This is a simple Laravel Service Provider providing for Generic JSON RPC
Installation
To install the PHP client library using Composer:
composer require chendujin/bitcoin
Laravel 5.5+
If you're using Laravel 5.5 or above, the package will automatically register the Bitcoin
provider and facade.
Laravel 5.4 and below
Add Chendujin\Bitcoin\BitcoinServiceProvider
to the providers
array in your config/app.php
:
'providers' => [ // Other service providers... Chendujin\Bitcoin\BitcoinServiceProvider::class, ],
If you want to use the facade interface, you can use
the facade class when needed:
use Chendujin\Bitcoin\Facade\Bitcoin;
Or add an alias in your config/app.php
:
'aliases' => [ ... 'Bitcoin' => Chendujin\Bitcoin\Facade\Bitcoin::class, ],
Configuration
You can use artisan vendor:publish
to copy the distribution configuration file to your app's config directory:
php artisan vendor:publish --provider="Chendujin\Bitcoin\BitcoinServiceProvider"
Then update config/bitcoin.php
with your credentials. Alternatively, you can update your .env
file with the following:
BTC_USER=xyy BTC_SECRET=xyy BTC_HOST=http://localhost BTC_PORT=8332
Usage
To use the Bitcoin Client Library you can use the facade, or request the instance from the service container:
try{ $ret = \Chendujin\Bitcoin\Facade\Bitcoin::getnewaddress('123456'); print_r($ret); }catch (Exception $e){ echo $e->getMessage(); }
Or
$bitcoin = app('Bitcoin'); $result=$bitcoin->getnewaddress('123456');