返回 Skill 列表
extension
分类: 开发与工程无需 API Key

laravel:custom-helpers

创建并注册小型、纯粹的帮助函数,以提高清晰度;保持它们有条理且经过测试

person作者: jakexiaohubgithub

Custom Helpers

Create a helper file

// app/Support/helpers.php
function money(int $cents): string { return number_format($cents / 100, 2); }

Autoload

Add to composer.json:

{
  "autoload": { "files": ["app/Support/helpers.php"] }
}

Run composer dump-autoload.

Guidelines

  • Keep helpers small and pure; avoid hidden IO/state
  • Prefer static methods on value objects when domain-specific