Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Config Laravel Package

hyperf/config

Hyperf/Config is the configuration component for the Hyperf framework. It loads and merges PHP config files, reads values with dot notation, supports environment variables, and provides coroutine-safe configuration access for high-performance, Swoole-based PHP applications.

Deep Wiki
Context7

At a glance

Frequently asked questions about Config
What is hyperf/config and what does it do?
hyperf/config is the configuration component for the Hyperf framework. It loads PHP config files, merges them, exposes nested values with dot notation, reads environment variables through env(), and binds a PSR-11 ConfigInterface into Hyperf’s dependency injection container. It is built for Hyperf’s Swoole-based, coroutine-driven runtime.
How do I install hyperf/config in a Hyperf project?
Install it with composer require hyperf/config. Most Hyperf skeleton projects already include it, so check composer.json before adding it manually. Then place configuration files under the config directory, typically config/autoload, and let Hyperf load them at bootstrap.
Is hyperf/config a Laravel package or compatible with Laravel?
No. hyperf/config is a Hyperf component, not a Laravel package, and it does not register Laravel service providers or use Laravel’s config repository. The API feels familiar because it supports dot notation and env() helpers, but you should use Laravel’s own config system in Laravel applications. For Hyperf apps, it is the native configuration layer.
How does dot-notation configuration access work in hyperf/config?
Use ConfigInterface::get('app.name') to read nested arrays by separating keys with dots. get() accepts a default as the second argument, and has() checks whether a key exists. You can also set values at runtime with set(), though runtime changes should be handled carefully in long-running Swoole workers.
How do I use env() and environment variables with hyperf/config?
The env() helper reads environment variables and is commonly called inside PHP config files, for example env('APP_ENV', 'prod'). Hyperf loads environment values during bootstrap, so config is the preferred access point at runtime. Avoid calling env() deep inside request handlers because environment loading happens early and values are cached in config.
How do I merge or override configuration values in Hyperf?
Configuration files are loaded and merged, so later sources can override earlier keys, and packages can ship defaults that you override in your app config. Use ConfigInterface::set() for controlled runtime overrides, or publish a package’s config file and edit the copy under your config directory. Keep overrides in config files or environment-specific config rather than scattering them through code.
How do I inject ConfigInterface into my Hyperf classes?
Type-hint ConfigInterface in a constructor and Hyperf’s container will inject it automatically. For example, public function __construct(private ConfigInterface $config) gives you access to get(), has(), and set(). You can also pull it from the PSR-11 container if you are not using constructor injection.
Is hyperf/config coroutine-safe for production Swoole applications?
Yes for read access. Configuration is loaded into memory at startup, and reading from ConfigInterface does not perform file I/O per request, which suits Swoole coroutines. Avoid mutating shared config during concurrent requests; if you need request-specific settings, resolve them before the server starts or keep them in coroutine context instead.
How do I test classes that depend on ConfigInterface?
Instantiate Hyperf\Config\Config with a plain array and inject it into the class under test, or mock ConfigInterface with your test framework. This avoids booting the full Hyperf application for simple config-dependent units. For integration tests, boot the container and assert that your config files merged as expected.
What are alternatives to hyperf/config and how is it maintained?
Within Hyperf, hyperf/config is the standard configuration component and is versioned with the framework, so match its major version to your Hyperf version. Alternatives depend on your stack: Laravel’s config repository for Laravel, Symfony Config for standalone PHP, or simple arrays for small scripts. For Hyperf and Swoole services, staying with hyperf/config keeps container integration and dot-notation behavior consistent.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
vento/laravel-airbrake
wfeller/laravel-batch
maco-studios/mage-os-installer
busarm/armie
siberfx/laravel-logger
kfteam1991/dcat-admin
dashed/dashed-laposta
dashed/dashed-ecommerce-montaportal
dashed/dashed-ecommerce-etsy
neohq/string-blade-compiler
log1x/acf-composer
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager