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:

$output = shell_exec("./bitcoin-cli getbalance");
echo var_dump($output); 

bitcoin-cli file path:


please tell me what i do?

2 Answers 2


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


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 and acknowledge you have read our privacy policy.

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