1
I am attempting to set up the PHP bitwasp library from the github repository:
https://github.com/Bit-Wasp/bitcoin-php
The installing instructions suggest I simply execute:
$ composer require bitwasp/bitcoin
I do have composer installed but I am getting the following error message:
Problem 1
- Installation request for bitwasp/bitcoin dev-master -> satisfiable by bitwasp/bitcoin[dev-master].
- Can only install one of: bitwasp/bitcoin[v0.0.29.1, dev-master].
- Installation request for bitwasp/bitcoin v0.0.29.1 -> satisfiable by bitwasp/bitcoin[v0.0.29.1].
I do not practice PHP full time so I lack the experience of installing packages in that language and using composer. I would be grateful if someone could point me in the right direction.
EDIT The suggestion has been made that the package is already installed. However, the following code sample which I got from another thread:
<?php
// failing to install bitwasp
use BitWasp\Bitcoin\Bitcoin;
use BitWasp\Bitcoin\Address;
use BitWasp\Bitcoin\Key\PrivateKeyFactory;
$network = Bitcoin::getNetwork();
$privateKey = PrivateKeyFactory::create(true);
$publicKey = $privateKey->getPublicKey();
$address = $publicKey->getAddress();
?>
is giving me PHP Fatal error: Class 'BitWasp\Bitcoin\Bitcoin' not found.
1Did you include the vendor/autoload.php file? It's missing from your snippet, so as suggested below, it might already be on your system. – karimkorun – 2016-08-25T20:25:43.640
2You have made me very happy !!! First of all I had to type
composer installinstead ofcomposer require bitswap/bitcoinand this triggered a proper installation, and in particular this created avendordirectory with anautoload.phpfile in it. Then I created a symbolic link from my working directory to thisvendordirectory. Then I added the linerequire 'vendor/autoload.php';in my snippet as you suggested. And voila the thing ran :) Thank you very much !!. If you want to explain the answer for the record (better than I can do, I am no PHP specialist) I will gladly upvote it. . – Sven Williamson – 2016-08-25T21:49:25.387Oh, please be careful :P someone published bitswap/bitcoin on composer and I'm not sure if they're typo-squatting! If you can, @Sven could you update your comment if this wasn't what you meant? – karimkorun – 2018-01-14T22:27:06.030
1
require 'vendor/autoload.php';For those having similar issues. – Sydwell – 2018-11-01T10:10:08.450