定制 enmaboya/strictness-for-laravel 二次开发

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

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

enmaboya/strictness-for-laravel

最新稳定版本:0.0.1

Composer 安装命令:

composer require enmaboya/strictness-for-laravel

包简介

more strictness for laravel

README 文档

README

A small Laravel package that adds strict, validated accessors for configuration values. It complements Laravel’s config layer - where values are usually defined in config/*.php and filled from environment variables - so mistakes surface as clear InvalidArgumentExceptions instead of subtle type or shape bugs later.

Requirements

  • PHP 8.2+
  • Laravel ^11.0 or ^12.0

Installation

composer require enmaboya/strictness-for-laravel

Usage

Config keys work as usual; strict methods read those keys and enforce types and optional constraints.

Strings (Enmaboya\StrictnessForLaravel\Enums\StringType):

  • DEFAULT - value must be a string
  • NON_EMPTY - non-empty after trim
  • NON_FALSY - non-empty string that is truthy in a PHP boolean sense
  • LOWERCASE / UPPERCASE - exact case match

Integers (Enmaboya\StrictnessForLaravel\Enums\IntType):

  • DEFAULT - value must be an int
  • POSITIVE / NEGATIVE / NON_ZERO / NON_NEGATIVE / NON_POSITIVE - as named
use Enmaboya\StrictnessForLaravel\Enums\StringType;
use Enmaboya\StrictnessForLaravel\Enums\IntType;
use Enmaboya\StrictnessForLaravel\Facades\StrictConfig;

// Facade (same underlying `config` binding after extend)
$apiUrl = StrictConfig::string('services.api.url', type: StringType::NON_EMPTY);
$timeout = StrictConfig::integer('services.api.timeout', default: 30, type: IntType::NON_NEGATIVE);

// Helper (PHPDoc assumes StrictConfigRepository)
$region = strict_config()->string('app.region', type: StringType::LOWERCASE);

Values like config('app.name') populated from env('APP_NAME') are read through the same keys; the strict layer only cares that the resolved config value matches the expected type and constraint.

Feature checklist

  • Strict string() reads with optional StringType validation
  • Strict integer() reads with optional IntType validation
  • Strict validatedString() reads with optional IntType validation
  • Strict validatedInteger() reads with optional IntType validation
  • Strict env()

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固