承接 kero/typesafe-env 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

kero/typesafe-env

最新稳定版本:0.1.3

Composer 安装命令:

composer require kero/typesafe-env

包简介

Wrapper around Laravel's Env to support type safety.

README 文档

README

Install via composer req kero/typesafe-env

GitHub latest tag codecov license: MIT

Usage

Assuming the following environment variables

API_URL=foo
APP_STRING_OR_NULL=null

APP_DEBUG=true
APP_LOG=false
APP_BOOL_OR_NULL=null

APP_PI=3

APP_BETTER_PI=3.14
use Kero\TypeSafeEnv\Env;

var_dump(Env::getString('API_URL')); // string(3) "foo"
var_dump(Env::getNullableString('APP_STRING_OR_NULL')); // NULL

var_dump(Env::getBool('APP_DEBUG')); // bool(true)
var_dump(Env::getBool('APP_LOG')); // bool(false)
var_dump(Env::getNullableBool('APP_BOOL_OR_NULL')); // NULL

var_dump(Env::getInt('APP_PI')); // int(3)

var_dump(Env::getFloat('APP_PI')); // float(3.14)

❗ Due to Laravel's implementation, both values null and (null) are treated as NULL.

Local Development

Code Style

Currently using plain PSR-12 via Laravel Pint. Apply the code style via

make pint

Tests

Using Pest for testing. Run existing tests via

make test

❗ Tests are relying on the environment variables defined in .env.testing

Type Coverage can also be tested via Pest. Current implementation inside Makefile is buggy ... (TODO: fix so command in Makefile via Docker can be used)

./vendor/bin/pest --type-coverage --min=100

Code Analysis

PHPStan is configured to check ./src/ and ./tests/ via

make analyse

Various

composer normalize

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-10-28