yangyifan/config-helper
A small Laravel helper package for working with configuration values, offering convenient utilities to read, set, and manage app config more easily. Useful for developers who want lightweight config shortcuts without adding a heavier dependency.
yangyifan/config-helper is a small Laravel utility package in the config-access niche — the kind of thing you reach for when config('foo.bar', $default) isn't expressive enough and you want typed retrieval, safe defaults, or runtime mutation without dragging in a full settings package. Given its footprint (1 star, 0 dependents), treat it as "read the source before you composer require" rather than "install and go."
Minimal steps:
composer.json for the illuminate/support constraint, then read src/ top to bottom — at this size the entire package is likely one service provider plus a helper file or facade. Confirm which it is; that determines whether you call functions (config_get()-style) or a facade (ConfigHelper::get()).composer require yangyifan/config-helper. Laravel 5.5+ auto-discovers the provider via extra.laravel.providers; on older skeletons add it to config/app.php.php artisan vendor:publish --provider="Yangyifan\ConfigHelper\ConfigHelperServiceProvider" (adjust namespace to the real one). If there's no config file, there's nothing to publish and the package is pure helper functions.config('services.foo.timeout', 30) with the package's typed accessor and assert it returns an int, not the string "30" your .env actually contains. That single test tells you whether the package solves your real problem or just renames config().If step 4 doesn't produce a clear win, stop — the native config() helper plus a thin custom helper in app/Support/helpers.php gives you the same thing with zero dependency risk.
Typed access at the call site. The core value of a config helper is usually coercion. Use it where .env values bite you — booleans ("false" is truthy as a string), integers from env, and comma-separated lists. Wrap the read once in your own accessor and let the package do the casting:
// app/Support/Settings.php
public static function timeout(): int
{
return (int) config('services.api.timeout', 30);
}
If the package offers ConfigHelper::getInt() / getBool() / getArray(), prefer those internally so the coercion rule lives in one place, but keep the static wrapper so you can swap the implementation later without touching call sites.
Runtime overrides for testing. The most defensible day-to-day use is mutating config mid-request in feature tests — forcing a feature flag on, pointing a client at a fake endpoint. Do it in setUp() and restore in tearDown(), or lean on Laravel's config([...]) which this package almost certainly delegates to:
protected function setUp(): void
{
parent::setUp();
config(['features.new_checkout' => true]);
}
Don't let the helper become a second, parallel config store. Two sources of truth for features.new_checkout is a debugging nightmare.
Boot-time validation. A genuinely useful pattern for a config helper is asserting required keys exist and match an expected type as the app boots. Register a check in a service provider's boot() and throw early rather than discovering a missing key in a queued job at 3am:
public function boot()
{
foreach (['services.stripe.key', 'services.stripe.secret'] as $key) {
if (blank(config($key))) {
throw new RuntimeException("Missing config: {$key}");
}
}
}
If the package exposes a validator, use it; otherwise hand-roll — the pattern matters more than the library.
Environment-scoped defaults. Use the helper to centralize fallback chains — production values from env, sensible defaults in config/, and test overrides in phpunit.xml via <env> entries. Keep the chain in config/*.php and treat the helper purely as the reader.
Integration with service providers. Bind configured objects (HTTP clients, mailers, SDKs) as singletons in a provider, reading config inside the closure. This is where a typed helper earns its keep — you catch a bad cast at container resolution, not at first request.
src/; at this size it's a 15-minute job and it's non-negotiable.illuminate/support constraint against your app's version. Packages this small are often pinned to whatever the author was running at publish time. If it says ^5.5|^6.0 and you're on 10/11, expect breakage in facades or provider registration.config:cache will bite you. Any mechanism that writes config at runtime stops working once php artisan config:cache has been run — the cached file is authoritative and runtime mutations aren't persisted. Never write config in a request path in production.singleton or scoped.config('a.b') where a is a string and b is requested — most helpers return null quietly instead of erroring.config(), Config::set(), and env() (only in config/ files!) cover 90% of this. Adopt the package only for a specific coercion or validation feature you can't do in three lines.php artisan tinker and dump the raw config('key') against what the helper returns. When they differ, you've found the package's coercion logic — which is exactly what you're paying for, and exactly where the bugs live.app/Support/ and dropping the dependency. You'll own it either way.How can I help you explore Laravel packages today?