delboy1978uk / phpbitcoin
A PHP service for connecting to bitcoind. Also compatible with Zend Framework 2.
Requires
- php: >=5.4.0
- guzzlehttp/guzzle: dev-master
Requires (Dev)
- codeception/aspect-mock: *
- codeception/codeception: dev-master
This package is auto-updated.
Last update: 2024-12-04 22:11:38 UTC
README
A PHP service for connecting to bitcoind. Also compatible with Zend Framework 2
##Installation
Installation is done through composer:
composer require delboy1978uk/phpbitcoin
##Usage
use Del\Bitcoin; $config = [ 'username' => 'YOURUSERNAME', // required 'password' => 'YOURPASSWORD', // required 'host' => '127.0.0.1', // default 'port' => '8332', // default 'protocol' => 'http', // default 'ssl_certificate' => '', // default @todo ]; $btc = new Bitcoin($config); //example $info = $btc->getControlApi()->getInfo(); /* sample output { "result":{ "version":119900, "protocolversion":70002, "walletversion":60000, "balance":0.00000000, "blocks":531329, "timeoffset":0, "connections":8, "proxy":"", "difficulty":1, "testnet":false, "keypoololdest":1439840037, "keypoolsize":101, "paytxfee":0.00000000, "relayfee":0.00001000, "errors":"" }, "error":null, "id":"phpbitcoin" } */
###API's The Bitcoin object has access to each of the different API's available
$btc->getBlockchainApi(); $btc->getControlApi(); $btc->getGeneratingApi(); $btc->getMiningApi(); $btc->getNetworkApi(); $btc->getRawTransactionApi(); $btc->getUtilityApi(); $btc->getWalletApi();
Each API has docblock comments from the documentation, so you should get nice code completion. However the actual Bitcoin API docs can be found at https://bitcoin.org/en/developer-reference#rpc-quick-reference
##Usage in ZF2 Still todo ##Installing bitcoind for development puPHPet files for Vagrant included. Just vagrant up, vagrant ssh, then install Bitcoin. Unfortunately the ability to add custom repositories is not in puPHPet (yet. see puphpet/puphpet#142)
sudo apt-get install python-software-properties
sudo add-apt-repository --yes ppa:bitcoin/bitcoin
sudo apt-get update
sudo apt-get install libboost-all-dev libdb4.8-dev libdb4.8++-dev bitcoind
cd ~
mkdir .bitcoin
cd .bitcoin
nano bitcoin.conf
Put the following info in the conf file:
server=1
daemon=1
testnet=1
rpcuser=phpbitcoin
rpcpassword=COMPLETELYrandomPASSWORD
You should use the testnet option if developing, tests connect on port 18332! Finally run bitcoind by simply typing it
bitcoind
Shut down bitcoind using the bitcoin-cli command
bitcoin-cli stop
##Donate If you like PHPBitcoin, spare half a shekel for an old ex leper. 1De1boyXJzdk4TYmHkR3st6dJmHuEaneHB