Download the PHP package inanepain/config without Composer

On this page you can find all versions of the php package inanepain/config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package config

= inanepain/config image:./icon.png[title=inanepain/xxx,25] :author: Philip Michael Raab :email: [email protected] :description: Configuration helpers. :keywords: inanepain, library, config :homepage: https://github.com/inanepain/config :copyright: Unlicense :revnumber: 0.4.0 :revdate: 2026-02-04 :experimental: :hide-uri-scheme: :icons: font :source-highlighter: highlight.js :toc: left :sectanchors: :idprefix: topic- :idseparator: - :pkg-vendor: inanepain :pkg-name: config :pkg-id: {pkg-vendor}/{pkg-name}

== image:./icon.png[title={pkg-id},25] {pkg-id}

{description}

:sectnums:

<<<

:leveloffset: +1

= Install

.composer [source,shell,subs=attributes+]

composer require {pkg-id}

:leveloffset!:

<<<

:leveloffset: +1

= Config

The Inane\\Config\\Config class is a small helper built on top of Inane\\Stdlib\\Options. It is used to:

The public API is intentionally small:

== Loading configuration from files

The default entry point is Config::fromConfigFile():

[source,php]

use Inane\Config\Config;

$config = Config::fromConfigFile();

By default it looks for config/app.config.php.

The base config file is expected to return an array (or something compatible with Options), e.g.:

[source,php]

// config/app.config.php

return [ // the default key inspected by Config::fromConfigFile() 'config' => [ // Optional: extra files to merge in (glob brace patterns supported) 'glob_pattern' => 'config/autoload/{{,.}global,{,.}local}.php',

    // Optional: prevent modifications after initial loading
    'allow_modifications' => false,
],

// application config (example)
'appId'    => 'inane-fw',
'services' => [
    // ...
],

];

If glob_pattern is set and matches files, each matching file is included and merged into the main config.

=== Config file merge order

The default glob_pattern merges \*.global.php before \*.local.php allowing for default configurations to be overridden with local ones. It is recommended to have a .gitignore file in the autoload directory to ignore \*.local.php in your commits.

..gitignore for autoload directory [source,git]

local.php *.local.php

== Locking and modifications

If allow_modifications is false (the default), Config::fromConfigFile() locks the configuration after loading/merging. This is a convenience to ensure your configuration is treated as immutable during runtime.

If you need a mutable config instance (for tests or dynamic environments), set:

[source,php]

return [ 'config' => [ 'allow_modifications' => true, ], ];

== Component / class-specific configuration

Config::getConfig(string $class) is a convention for retrieving configuration scoped to a specific class.

By default, it looks under the components key and then under the given class name:

[source,php]

use Inane\Config\Config;

/* @var Config $config / $serviceManagerConfig = $config->getConfig(Inane\Services\ServiceManager::class);

That means your config can be structured like this:

[source,php]

return [ 'components' => [ Inane\Services\ServiceManager::class => [ 'cache' => true, 'debug' => false, ], ], ];

NOTE: getConfig() returns null when no matching config is found. If you rely on class-specific config injection (see ConfigAware below), ensure the config entry exists for that class, or use global injection instead.

:leveloffset!:

<<<

:leveloffset: +1

:= ConfigManager

Inane\\Config\\ConfigManager is a small singleton that centralises configuration access and attribute-based injection.

It is primarily useful in bootstrapping code where you want to:

== Creating and initialising the manager

The manager is a singleton:

[source,php]

use Inane\Config\Config; use Inane\Config\ConfigManager;

$config = Config::fromConfigFile();

$configManager = ConfigManager::instance() ->setConfig($config);

If you don’t call setConfig() yourself, setConfigFor() will lazily initialise the manager with Config::fromConfigFile().

== Injecting configuration into an object

ConfigManager::setConfigFor(object $object) inspects the object via reflection and looks for the ConfigAwareAttribute.

When found, it will call setConfig() on the object:

In the framework, this is used during bootstrapping (see Knot\\Application::bootstrapObject()).

IMPORTANT: Config::getConfig() returns null when no matching config is found. If you use class-specific injection, ensure you provide a matching entry under components.

== Retrieving configuration from the manager

You can retrieve the manager’s configured ConfigInterface via getConfig().

[source,php]

use Inane\Config\ConfigManager;

$config = ConfigManager::instance()->getConfig();

When you pass a $key, the manager will first check that a configuration subset exists for that key. If it does not, it throws Inane\\Config\\Exception\\ConfigNotFoundException.

NOTE: To actually use the subset, call Config::getConfig($key) directly on the returned config instance.

:leveloffset!:

<<<

:leveloffset: +1

= ConfigAware helpers

The ConfigAware helpers provide a lightweight, opt-in way to inject configuration into objects.

They are designed to work with Inane\\Config\\Config but can also accept plain arrays or Inane\\Stdlib\\Options.

== Interface: ConfigAwareInterface

To be configurable, a class can implement Inane\\Config\\ConfigAware\\ConfigAwareInterface:

[source,php]

use Inane\Config\ConfigAware\ConfigAwareInterface; use Inane\Stdlib\Array\OptionsInterface;

class MyComponent implements ConfigAwareInterface { public function setConfig(array|OptionsInterface $config): void { // store config / initialise component } }

== Trait: ConfigAwareTrait

Most classes will use the provided trait instead of implementing the storage/locking logic themselves.

The trait:

Example:

[source,php]

use Inane\Config\ConfigAware\ConfigAwareInterface; use Inane\Config\ConfigAware\ConfigAwareTrait; use Inane\Stdlib\Array\OptionsInterface;

class MyComponent implements ConfigAwareInterface { use ConfigAwareTrait;

// Optional: default/fallback config values
protected array $defaultConfig = [
    'enabled' => true,
    'ttl'     => 60,
];

public function isEnabled(): bool {
    return (bool)($this->config->enabled ?? false);
}

}

NOTE: ConfigAwareTrait::setConfig() only applies once: after the internal config is locked, subsequent calls have no effect.

== Attribute: ConfigAwareAttribute

Inane\\Config\\ConfigAware\\ConfigAwareAttribute is a class attribute that can be used by a bootstrapper/container to decide how to inject configuration.

It has a single flag:

Example — global config injection:

[source,php]

use Inane\Config\ConfigAware\ConfigAwareAttribute; use Inane\Config\ConfigAware\ConfigAwareTrait;

[ConfigAwareAttribute(true)]

class ServiceManager { use ConfigAwareTrait; }

Example — class-specific injection:

[source,php]

use Inane\Config\ConfigAware\ConfigAwareAttribute; use Inane\Config\ConfigAware\ConfigAwareTrait;

[ConfigAwareAttribute]

class MyComponent { use ConfigAwareTrait; }

With class-specific injection, ensure your configuration provides a matching entry under components:

[source,php]

return [ 'components' => [ MyComponent::class => [ 'enabled' => true, ], ], ];

IMPORTANT: In the framework bootstrap implementation (see Knot\\Application::bootstrapObject()), when globalConfig=false the injector calls:

$object->setConfig($config->getConfig($object::class));

Since getConfig() can return null, class-specific injection requires that the class has a config entry. If you want a safe default without providing a components entry, prefer #[ConfigAwareAttribute(true)] and/or provide a $defaultConfig property on the class.

:leveloffset!:

<<<

:leveloffset: +1

:= Exceptions

== ConfigNotFoundException

Inane\\Config\\Exception\\ConfigNotFoundException is thrown when a requested configuration is missing.

It extends Inane\\Stdlib\\Exception\\ConfigurationException.

The exception is currently used by ConfigManager::getConfig($key) to fail fast when a class/component-specific configuration key does not exist.

[source,php]

use Inane\Config\ConfigManager; use Inane\Config\Exception\ConfigNotFoundException;

try { // Validate that the component config exists $config = ConfigManager::instance()->getConfig(MyComponent::class);

// Access the component-specific config via Config::getConfig()
$componentConfig = $config->getConfig(MyComponent::class);

} catch (ConfigNotFoundException $e) { // handle missing configuration (provide defaults, abort startup, etc.) }

:leveloffset!:


All versions of config with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
inanepain/stdlib Version >=0.6.0 || dev-master || dev-develop
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package inanepain/config contains the following files

Loading the files please wait ...