Installing PHP bitwasp bitcoin library

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.

Sven Williamson

Posted 2016-08-24T14:37:30.013

Reputation: 1 314

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 install instead of composer require bitswap/bitcoin and this triggered a proper installation, and in particular this created a vendor directory with an autoload.php file in it. Then I created a symbolic link from my working directory to this vendor directory. Then I added the line require '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.387

Oh, 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

1require 'vendor/autoload.php';For those having similar issues.Sydwell 2018-11-01T10:10:08.450

Answers

1

You have it installed already. That's why it's saying you have the requirements met and don't need to download it again.

Whyte the Weeabear

Posted 2016-08-24T14:37:30.013

Reputation: 530

Thank you very much ! I am guessing something else is wrong too. I have updated my question to explain.Sven Williamson 2016-08-24T21:16:18.030

I think I know why. Did you use "bitcoin" instead of "bitcoin-php"?Whyte the Weeabear 2016-08-24T21:18:56.613

I typed composer require bitwasp/bitcoin to install and the code is exactly as I have stated it. Using the indicated repository. I am on Debian 8.Sven Williamson 2016-08-24T21:22:03.040

Oh, im not familiar with Debian. What php version are you using?Whyte the Weeabear 2016-08-24T21:23:45.240

PHP 5.6.24. Zend Engine v2.6.0 with Zend OPcache v7.0.6-dev. This is pure PHP, run as a script (no browser involed), if this matters.Sven Williamson 2016-08-24T21:25:49.707