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 HandlingThe original library could fail when json_decode() returned null. The enhanced version includes proper JSON error checking:
if (json_last_error() !== JSON_ERROR_NONE) {
$this->error = 'JSON decode error: ' . json_last_error_msg();
return false;
}
2. Enhanced cURL ConfigurationAdded timeout controls, better user agent, and improved SSL handling:
CURLOPT_TIMEOUT => 30,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_USERAGENT => 'EasyBitcoin-PHP Enhanced/1.1'
3. Robust Error HandlingBetter detection and reporting of various error conditions including HTTP errors, connection failures, and RPC errors.
4. Maintained CompatibilityThe API remains identical to the original - just replace your easybitcoin.php file and you're good to go!
Usage (Same as Original):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-EnhancedTesting: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!