jalallinux/price-feed 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jalallinux/price-feed

Composer 安装命令:

composer require jalallinux/price-feed

包简介

Price Feed is a Laravel package for fetching real-time prices of multiple asset types — including cryptocurrencies, fiat currencies, gold, silver, and metal derivatives — through a unified driver-based architecture.

README 文档

README

Latest Version on Packagist Total Downloads Software License

A comprehensive Laravel package for fetching real-time prices of multiple asset types including cryptocurrencies, fiat currencies, gold, silver, and precious metal derivatives through a unified driver-based architecture.

Features

  • Multi-Asset Support: Cryptocurrencies, fiat currencies, and precious metals
  • Driver-Based Architecture: Easily extensible with multiple data providers
  • Built-in Caching: Configurable caching with TTL support
  • Type Safety: Full PHP 8.4+ type safety with enums and DTOs
  • Laravel Integration: Seamless Laravel service provider and facade integration
  • Multiple Providers: Support for TGJU, Brsapi, and TGN APIs
  • Comprehensive Testing: Full test coverage with Pest PHP

Supported Assets

Cryptocurrencies

  • Bitcoin (BTC), Ethereum (ETH), Tether (USDT)
  • Binance Coin (BNB), XRP, Cardano (ADA)
  • Dogecoin (DOGE), Solana (SOL), TRON (TRX)
  • Polkadot (DOT), Polygon (MATIC), Litecoin (LTC)
  • Shiba Inu (SHIB), Avalanche (AVAX)
  • Uniswap (UNI), Chainlink (LINK)

Fiat Currencies

  • USD, EUR, GBP, JPY, CNY
  • AUD, CAD, CHF, IRR, AED, TRY

Precious Metals

  • Gold (various purities and forms)
  • Silver (999, 925, ounce)
  • Platinum, Palladium
  • Iranian Gold Coins (various denominations)

Installation

You can install the package via Composer:

composer require jalallinux/price-feed

The package will automatically register its service provider and facade.

Configuration

Publish the configuration file:

php artisan vendor:publish --provider="JalalLinuX\PriceFeed\PriceFeedServiceProvider" --tag="config"

Configure your environment variables:

# Default driver
PRICE_FEED_DRIVER=tgju

# TGJU Configuration
TGJU_CACHE_ENABLED=true
TGJU_CACHE_TTL=120

# Brsapi Configuration
BRSAPI_API_KEY=your_api_key_here
BRSAPI_CACHE_ENABLED=true
BRSAPI_CACHE_TTL=120

# TGN Configuration
TGN_USERNAME=your_username
TGN_API_KEY=your_api_key
TGN_CACHE_ENABLED=true
TGN_CACHE_TTL=120

Usage

Basic Usage

use JalalLinuX\PriceFeed\Facades\PriceFeed;
use JalalLinuX\PriceFeed\Enums\Currency;

// Get price for a single currency
$btcPrice = PriceFeed::price(Currency::BTC);

// Get prices for multiple currencies
$prices = PriceFeed::prices([
    Currency::BTC,
    Currency::ETH,
    Currency::USD
]);

// Get all supported currencies
$supportedCurrencies = PriceFeed::supportedCurrencies();

// Get available drivers
$drivers = PriceFeed::availableDrivers();

Using Specific Drivers

// Use a specific driver
$btcPrice = PriceFeed::driver('brsapi')->getPrice(Currency::BTC);

// Get prices from specific driver
$prices = PriceFeed::driver('tgn')->getPrices([
    Currency::USD,
    Currency::EUR
]);

Working with Price Data

$priceData = PriceFeed::price(Currency::BTC);

echo $priceData->currency->value; // BTC
echo $priceData->price; // 125000000.0
echo $priceData->unit->value; // IRR
echo $priceData->symbol; // BTC
echo $priceData->change24h; // 2500000.0
echo $priceData->changePercentage24h; // 2.04
echo $priceData->high24h; // 130000000.0
echo $priceData->low24h; // 120000000.0
echo $priceData->timestamp->format('Y-m-d H:i:s'); // 2024-01-15 14:30:00

Cache Management

// Clear cache for specific currency
PriceFeed::clearCache(Currency::BTC);

// Clear cache for specific driver
PriceFeed::clearCache(null, 'tgju');

// Clear all cache
PriceFeed::clearCache();

Available Drivers

TGJU Driver

  • Provider: TGJU (Tehran Gold and Jewelry Union)
  • Coverage: Fiat currencies, precious metals
  • Unit: Iranian Rial (IRR)
  • Authentication: None required
  • API: Free public API

Brsapi Driver

  • Provider: Brsapi.ir
  • Coverage: Cryptocurrencies, fiat currencies, precious metals
  • Unit: Iranian Toman (IRT)
  • Authentication: API key required
  • API: Commercial API

TGN Driver

  • Provider: TGN Services
  • Coverage: Fiat currencies, precious metals, coins
  • Unit: Iranian Toman (IRT)
  • Authentication: Username and API key required
  • API: Commercial API

Configuration Reference

The package configuration is located in config/price-feed.php:

return [
    'default' => env('PRICE_FEED_DRIVER', 'tgju'),
    
    'drivers' => [
        'tgju' => [
            'driver' => \JalalLinuX\PriceFeed\Drivers\TgjuDriver::class,
            'base_url' => 'https://call5.tgju.org',
            'unit' => \JalalLinuX\PriceFeed\Enums\CurrencyUnit::IRR,
            'cache_enabled' => true,
            'cache_ttl' => 120,
            'currencies' => [
                // Configured currencies
            ],
        ],
        // Other drivers...
    ],
];

Testing

Run the tests with:

composer test

Run tests with coverage:

composer test-coverage

Code Quality

Format code with Laravel Pint:

composer format

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email smjjalalzadeh93@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Support

If you find this package useful, please consider starring it on GitHub and sharing it with others!

jalallinux/price-feed 适用场景与选型建议

jalallinux/price-feed 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 10 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「jalallinux」 「price-feed」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 jalallinux/price-feed 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 jalallinux/price-feed 我们能提供哪些服务?
定制开发 / 二次开发

基于 jalallinux/price-feed 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 24
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-07