for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SimpleCMS\Bank;
use Illuminate\Support\Str;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Validator;
use SimpleCMS\Bank\Validation\Rule\BankRule;
use SimpleCMS\Bank\Validation\Rule\BankBinRule;
use SimpleCMS\Bank\Validation\Rule\BankCardRule;
use SimpleCMS\Bank\Validation\Rule\BankCodeRule;
class BankServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*/
public function boot(): void
$this->loadedHelpers();
$this->loadFacades();
$this->loadedValidator();
}
* 加载验证
*
* @author Dennis Lui <[email protected]>
* @return void
protected function loadedValidator(): void
Validator::extend(
'bank',
BankRule::class
);
'bank_card',
BankCardRule::class
'bank_code',
BankCodeRule::class
'bank_bin',
BankBinRule::class
* 绑定Facades
protected function loadFacades(): void
$this->app->bind('bank', fn() => new \SimpleCMS\Bank\Packages\Bank(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '/data/banks.json'));
* 加载辅助函数
protected function loadedHelpers(): void
foreach (scandir(__DIR__ . DIRECTORY_SEPARATOR . 'helpers') as $helperFile) {
$path = sprintf(
'%s%s%s%s%s',
__DIR__,
DIRECTORY_SEPARATOR,
'helpers',
$helperFile
if (!is_file($path)) {
continue;
$function = Str::before($helperFile, '.php');
if (function_exists($function)) {
require_once $path;