khetamhamdy/currency-exchange
Composer 安装命令:
composer require khetamhamdy/currency-exchange
包简介
A Laravel package for currency exchange and transaction management.
README 文档
README
Introduction
The Currency Exchange package is an open-source PHP library for Laravel that simplifies managing currency exchange operations and transactions. If your application involves working with currencies or financial transactions between currencies, this package provides an efficient solution.
This package is dedicated to my late father, and I hope it helps improve the software development experience.
Features
- Manage currencies: Add, update, delete, and view currencies.
- Manage exchange transactions: Add, update, view exchange transactions.
- Flexible API for currency and transaction data in JSON format.
- Easy to use and works seamlessly with Laravel 9.0+.
Installation
1. Install via Composer
Install the package in your Laravel application by running the following command in your project directory:
composer require khetamhamdy/currency-exchange
2. Add the Service Provider (if needed)
If you're not using Laravel's package auto-discovery feature, add the service provider manually in the config/app.php file under the providers array:
'providers' => [ // Other providers... KhetamHamdy\CurrencyExchange\Providers\CurrencyExchangeServiceProvider::class, ],
3. Run Migrations
To create the necessary database tables, execute the following command:
php artisan migrate
This will run the migrations provided by the package to set up the required database schema.
Usage
1. Currency Management
Display All Currencies:
use KhetamHamdy\CurrencyExchange\Services\CurrencyService; $currencyService = app('currency.service'); $currencies = $currencyService->getAllCurrencies();
Add a New Currency:
$currencyService->addCurrency([ 'name' => 'US Dollar', 'code' => 'USD', ]);
Update a Currency:
$currencyService->updateCurrency($id, [ 'name' => 'Euro', 'code' => 'EUR', ]);
Delete a Currency:
$currencyService->deleteCurrency($id);
2. Transaction Management
Display All Transactions:
use KhetamHamdy\CurrencyExchange\Services\ExchangeTransactionService; $exchangeService = app('exchange.service'); $transactions = $exchangeService->listTransactions();
Add a New Transaction:
$exchangeService->createTransaction([ 'from' => 1, // Original currency ID 'to' => 2, // Target currency ID 'rate' => 1.2, 'date' => now(), ]);
Update a Transaction:
$exchangeService->updateTransaction($id, [ 'from' => 1, 'to' => 2, 'rate' => 1.3, 'date' => now(), ]);
Notes
- Ensure your application meets the package requirements, including Laravel version 9.0 or higher.
- Remember to run
php artisan migrateafter installing the package to set up the database tables.
License
This package is open-sourced software licensed under the MIT license.
khetamhamdy/currency-exchange 适用场景与选型建议
khetamhamdy/currency-exchange 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 4, 最近一次更新时间为 2025 年 01 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 khetamhamdy/currency-exchange 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 khetamhamdy/currency-exchange 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-05