anexponent/laravel-wallet
Composer 安装命令:
composer require anexponent/laravel-wallet
包简介
A modern Laravel package providing a simple virtual wallet system.
README 文档
README
A modern, simple, and flexible virtual wallet system for Laravel.
This package allows you to attach a wallet to any model (usually a User), deposit and withdraw credits, and keep a full transaction history. Ideal for apps where users buy credits or virtual currency to spend on services or goods.
Features
Assign a wallet to any model (User, Member, etc.) Track deposits, withdrawals, refunds, and custom transaction types Transaction metadata for payment references or descriptions Safe balance updates using database transactions Force withdrawals or failed deposits Configurable models for Wallet, Transaction, and User Supports Laravel 9, 10, and 11
Installation
Install the package with composer:
composer require anexponent/tgr-laravel-wallet
The package automatically merges default configuration, so you can start using it immediately.
Run Migrations
php artisan migrate
Publish the migrations with this artisan command:
Optional: You can publish the migrations if you want to customize them:
php artisan vendor:publish --provider="Anexponent\Wallet\WalletServiceProvider" --tag=migrations
Configuration
Default configuration is already merged automatically. The defaults are:
return [ 'user_model' => App\Models\User::class, 'wallet_model' => Anexponent\Wallet\Wallet::class, 'transaction_model' => Anexponent\Wallet\Transaction::class, ];
Optional: You can publish the config to customize it:
php artisan vendor:publish --provider="Anexponent\Wallet\WalletServiceProvider" --tag=config
This will merge the config.php config file where you can specify the Users, Wallets & Transactions classes if you have custom ones.
Usage
Add the HasWallet trait to your User model.
use Anexponent\Wallet\HasWallet; class User extends Model { use HasWallet; ... }
At some point before making transactions, create the user's wallet.
$user->wallet()->firstOrCreate([]);
Then you can easily make transactions from your user model.
$user = User::find(1); $user->balance; // 0 $user->deposit(100); $user->balance; // 100 $user->withdraw(50); $user->balance; // 50 $user->forceWithdraw(200); $user->balance; // -150
You can easily add meta information to the transactions to suit your needs.
$user = User::find(1); $user->deposit(100, 'deposit', ['stripe_source' => 'ch_BEV2Iih1yzbf4G3HNsfOQ07h', 'description' => 'Deposit of 100 credits from Stripe Payment']); $user->withdraw(10, 'withdraw', ['description' => 'Purchase of Item #1234']);
Transactions
Retrieve all transactions:
$transactions = $user->transactions;
Get signed amount
$transaction->signed_amount;
Each transaction includes: amount type accepted meta (array) balance (after transaction) hash (unique ID)
Security
If you discover any security related issues, please email simon@webartisan.be instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
anexponent/laravel-wallet 适用场景与选型建议
anexponent/laravel-wallet 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「money」 「laravel」 「wallet」 「balance」 「credits」 「virtual-currency」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 anexponent/laravel-wallet 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 anexponent/laravel-wallet 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 anexponent/laravel-wallet 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Beyonic PHP Library
The BlockTrail PHP SDK, for integration of Bitcoin functionality through the BlockTrail API
Library for validation of cryptocoin wallets
The Payum Yandex Money gateway
Alfabank REST API integration
Yoke: SSH Connection Manager/Wallet
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-03