2

i installed a bitcoind core and i access bitcoin-cli command in linux terminal with developer command(getbalance, getaccountaddress etc.) but i want run this command in php file.

my php code is:

chdir('/home/itr/Downloads/bitcoin/bin');
$output = shell_exec("./bitcoin-cli getbalance");
echo var_dump($output); 

bitcoin-cli file path:

/home/itr/Downloads/bitcoin/bin

please tell me what i do?

3

I would definitely not do it this way and use a RPC client. A very simple one is https://github.com/aceat64/EasyBitcoin-PHP

0

You have a couple of approaches:

  1. Use some well written JSON/RPC php client like this php-json-rpc-http [For using via HTTPS] or php-json-rpc-ssh [For using via SSH] along with implementing calls on your own based on Bitcoin's Reference API CallsList. Bitcoin RPC quick reference is also very helpful.
  2. Completely rely on PHP-BitconRPC, which is a well unit-tested all-in-one library using Guzzle

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.