定制 notchpay/laravel-toolkit 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

notchpay/laravel-toolkit

Composer 安装命令:

composer require notchpay/laravel-toolkit

包简介

This is my package laravel-toolkit

README 文档

README

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

Installation

You can install the package via composer:

composer require notchafrica/laravel-toolkit

You can publish and run the migrations with:

php artisan vendor:publish --tag="laravel-toolkit-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="laravel-toolkit-config"

This is the contents of the published config file:

return [
    "currency" => [
        'default' => 'USD',

        /*
        |--------------------------------------------------------------------------
        | API Key for FOREXAPI
        |--------------------------------------------------------------------------
        |
        | Only required if you with to use the Open Exchange Rates api. You can
        | always just use Yahoo, the current default.
        |
        */

            'api_key' => env(
                "RESTUNIVERE_API_KEY",
            ),

        /*
        |--------------------------------------------------------------------------
        | Default Storage Driver
        |--------------------------------------------------------------------------
        |
        | Here you may specify the default storage driver that should be used
        | by the framework.
        |
        | Supported: "database", "filesystem", "Model"
        |
        */

            'driver' => 'filesystem',

        /*
        |--------------------------------------------------------------------------
        | Default Storage Driver
        |--------------------------------------------------------------------------
        |
        | Here you may specify the default cache driver that should be used
        | by the framework.
        |
        | Supported: all cache drivers supported by Laravel
        |
        */

        'cache_driver' => null,

        /*
        |--------------------------------------------------------------------------
        | Storage Specific Configuration
        |--------------------------------------------------------------------------
        |
        | Here you may configure as many storage drivers as you wish.
        |
        */

        'drivers' => [

            'database' => [
                'class' => \Notch\Toolkit\Currency\Drivers\Database::class,
                'connection' => null,
                'table' => 'currencies',
            ],

            'filesystem' => [
                'class' => \Notch\Toolkit\Currency\Drivers\Filesystem::class,
                'disk' => "local",
                'path' => 'currencies.json',
            ],

            'model' => [
                'table' => 'currencies',
                'class' => \Notch\Toolkit\Currency\Models\Currency::class
            ],

        ],

        /*
        |--------------------------------------------------------------------------
        | Currency Formatter
        |--------------------------------------------------------------------------
        |
        | Here you may configure a custom formatting of currencies. The reason for
        | this is to help further internationalize the formatting past the basic
        | format column in the table. When set to `null` the package will use the
        | format from storage.
        |
        |
        */

        'formatter' => null,

        /*
        |--------------------------------------------------------------------------
        | Currency Formatter Specific Configuration
        |--------------------------------------------------------------------------
        |
        | Here you may configure as many currency formatters as you wish.
        |
        */

        'formatters' => [

            'php_intl' => [
                'class' => \Notch\Toolkit\Currency\Formatters\PHPIntl::class,
            ],

        ],
    ]
];

Optionally, you can publish the views using

php artisan vendor:publish --tag="laravel-toolkit-views"

Currency

The Laravel Currency Toolkit makes it easy to implement multi-currency pricing into your application and store the exchange data for fast real-time conversions.

Usage

The simplest way to use these methods is through the helper function currency() or by using the facade. For the examples below we will use the helper method.

Converting

This is a shortcut to the most commonly used convert method, which converts the given amount into the provided currency.

currency($amount, $from = null, $to = null, $format = true)

Arguments:

$amount - The float amount to convert $from - The current currency code of the amount. If not set, the application default will be used (see config/notchpay-toolkit.php file). $to - The currency code to convert the amount to. If not set, the user-set currency is used. $format - Should the returned value be formatted.

Usage:

echo currency(12.00);               // Will format the amount using the user selected currency
echo currency(12.00, 'USD', 'EUR'); // Will format the amount from the default currency to EUR

Formatting

Quickly parse a given amount into the proper currency format. This is a shortcut to the most commonly used format method.

currency_format($amount, $code = null)

Manage

Easily add, update, or delete currencies from the default storage. This is extremely helpful when there are changes to currency data, such as symbols and such.

php artisan currency:<action>

Arguments:

 action              Action to perform (hydrate, seed, or cleanup)

Seed

Used to seed currencies in local database

php artisan currency:seed

Updating Exchange

Update exchange rates from restuniverse.com An API key is needed to use Rest Universe. Add yours to the config file.

php artisan currency:hydrate

Note: Yahoo has discontinued the use of their exchange rate API, so it has been removed from the package.

Cleanup

Used to clean the Laravel cached exchanged rates and refresh it from the database. Note that cached exchanged rates are cleared after they are updated using one of the command above.

php artisan currency:cleanup

Testing

composer test

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

notchpay/laravel-toolkit 适用场景与选型建议

notchpay/laravel-toolkit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 660 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 09 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 notchpay/laravel-toolkit 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-09-20