2017 © Pedro Peláez
 

library phpbitcoin

A PHP service for connecting to bitcoind. Also compatible with Zend Framework 2.

image

delboy1978uk/phpbitcoin

A PHP service for connecting to bitcoind. Also compatible with Zend Framework 2.

  • Friday, August 28, 2015
  • by delboy1978uk
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

PHPBitcoin

Build Status Code Coverage Scrutinizer Code Quality
A PHP service for connecting to bitcoind. Also compatible with Zend Framework 2, (*1)

Installation

Installation is done through composer:, (*2)

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, (*3)

$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, (*4)

Usage in ZF2

Still todo, (*5)

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 https://github.com/puphpet/puphpet/issues/142), (*6)

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:, (*7)

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, (*8)

bitcoind

Shut down bitcoind using the bitcoin-cli command, (*9)

bitcoin-cli stop

If you like PHPBitcoin, spare half a shekel for an old ex leper. 1De1boyXJzdk4TYmHkR3st6dJmHuEaneHB, (*10)

The Versions

28/08 2015

dev-master

9999999-dev

A PHP service for connecting to bitcoind. Also compatible with Zend Framework 2.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Derek McLean