Bitcoin Forum
September 18, 2025, 12:54:38 PM *
News: Latest Bitcoin Core release: 29.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: EasyBitcoin-PHP Enhanced - Updated Version with Bug Fixes  (Read 34 times)
mandias (OP)
Full Member
***
Offline Offline

Activity: 202
Merit: 106


View Profile
September 17, 2025, 01:49:50 PM
Merited by ABCbits (6)
 #1

Fellow Bitcoin developers,

I've created an enhanced version of the popular EasyBitcoin-PHP library that addresses several critical issues while maintaining full backward compatibility. The original library by aceat64 has been a cornerstone for PHP Bitcoin development, but it has some known issues with modern PHP versions and Bitcoin Core.

What's New:

Fixed the infamous "line 187 error" - Better null response handling
Enhanced JSON parsing - Proper error checking for malformed responses 
Improved cURL configuration - Better timeout and connection handling
Modern PHP compatibility - Works with PHP 7.4+ and PHP 8.x
Better SSL support - Enhanced HTTPS connections
Comprehensive error reporting - More detailed error messages

Key Improvements:

1. JSON Response Handling
The original library could fail when json_decode() returned null. The enhanced version includes proper JSON error checking:
Code:
if (json_last_error() !== JSON_ERROR_NONE) {
    $this->error = 'JSON decode error: ' . json_last_error_msg();
    return false;
}

2. Enhanced cURL Configuration
Added timeout controls, better user agent, and improved SSL handling:
Code:
CURLOPT_TIMEOUT => 30,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_USERAGENT => 'EasyBitcoin-PHP Enhanced/1.1'

3. Robust Error Handling
Better detection and reporting of various error conditions including HTTP errors, connection failures, and RPC errors.

4. Maintained Compatibility
The API remains identical to the original - just replace your easybitcoin.php file and you're good to go!

Usage (Same as Original):
Code:
require_once('easybitcoin_enhanced.php');
$bitcoin = new Bitcoin('username','password');
$info = $bitcoin->getinfo();
if($info === false) {
    echo "Error: " . $bitcoin->error;
} else {
    print_r($info);
}

Why This Matters:

Many developers still rely on the original EasyBitcoin-PHP for production applications. While newer libraries exist (like denpa/php-bitcoinrpc), they require Composer and additional dependencies. This enhanced version provides a drop-in replacement that:

- Fixes critical bugs without changing the API
- Requires no additional dependencies
- Works with modern Bitcoin Core versions
- Maintains the simplicity that made the original popular

Credits:
This work is based on the original EasyBitcoin-PHP by aceat64. All credit for the original design and concept goes to the original author. This enhancement aims to keep the library alive and functional for the community.

Download:
https://github.com/byshigenobu/EasyBitcoin-PHP-Enhanced

Testing:
Tested with:
- PHP 7.4, 8.0, 8.1, 8.2
- Bitcoin Core 22.1, 24.2, 25.2 and 27.2
- Various altcoins (Litecoin & Dogecoin)

Feel free to test and provide feedback. Let's keep this useful library maintained for the community!

Future Plans:
- Add batch request support
- Include more comprehensive examples
- Add unit tests

Happy coding!
shinohai
Full Member
***
Online Online

Activity: 273
Merit: 111



View Profile
September 17, 2025, 03:02:43 PM
 #2

Nice work! Got a little nostalgic checking out the Github repo, as I used to toy with EasyBitcoin-PHP a long time ago.

I always liked how it didn't require that composer crap, just dead simple to include in projects.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!