provides a nested object property based user interface for accessing this configuration data within application code

Overview

laminas-config

This package is considered feature-complete, and is now in security-only maintenance mode, following a decision by the Technical Steering Committee. If you have a security issue, please follow our security reporting guidelines. If you wish to take on the role of maintainer, please nominate yourself

Build Status

laminas-config is designed to simplify access to configuration data within applications. It provides a nested object property-based user interface for accessing this configuration data within application code. The configuration data may come from a variety of media supporting hierarchical data storage.

Comments
  • PHP 7.4 introduced BC break with accessing null

    PHP 7.4 introduced BC break with accessing null

    This construct used to work, and pretty much the Zend Config is built around that accessing NULL as array yields no notices:

    $ php --version
    PHP 7.4.6 (cli) (built: May 29 2020 01:44:57) ( NTS )
    $ php -r '$a=null; $a["bla"];'
    PHP Notice:  Trying to access array offset on value of type null in Command line code on line 1
    
    • https://www.php.net/manual/en/migration74.incompatible.php:

    Array-style access of non-arrays ΒΆ

    Trying to use values of type null, bool, int, float or resource as an array (such as $null["key"]) will now generate a notice.

    rfc:

    • https://wiki.php.net/rfc/notice-for-non-valid-array-container
    opened by glensc 6
  • Use lowercase `config` key to get configuration from container

    Use lowercase `config` key to get configuration from container

    | Q | A |-------------- | ------ | QA | yes

    Description

    Port of https://github.com/zendframework/zend-config/pull/66

    Fixes #1

    Bug 
    opened by michalbundyra 4
  • Added Env processor to allows users to read the value of the getenv() function in static configuration files.

    Added Env processor to allows users to read the value of the getenv() function in static configuration files.

    This feature will allow getenv function to be run from static files like yaml.

    Using Zend\Config\Processor\Env

    This example illustrates the basic usage of Zend\Config\Processor\Env:

    putenv('AMQP_PASSWORD=guest');
    
    use Zend\Config\Config;
    use Zend\Config\Factory;
    use Zend\Config\Processor\Env as EnvProcessor;
    
    $config = new Config([
                'host' => '127.0.0.1',
                'port' => 5672,
                'username' => 'guest',
                'password' => 'env(AMQP_PASSWORD)',
                'vhost' => '/',
            ], true);
    
    $processor = new EnvProcessor;
    $processor->process($config);
    $config->setReadOnly();
    
    echo $config->amqp->password;
    

    This example returns the output: guest.


    Originally posted by @eguvenc at https://github.com/zendframework/zend-config/pull/52

    Awaiting Author Updates 
    opened by weierophinney 3
  • Configure Renovate

    Configure Renovate

    Mend Renovate

    Welcome to Renovate! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

    🚦 To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.


    Detected Package Files

    • composer.json (composer)
    • .github/workflows/auto-close.yml (github-actions)
    • .github/workflows/continuous-integration.yml (github-actions)
    • .github/workflows/docs-build.yml (github-actions)
    • .github/workflows/release-on-milestone-closed.yml (github-actions)

    Configuration Summary

    Based on the default config's presets, Renovate will:

    • Start dependency updates only once this onboarding PR is merged
    • Enable Renovate Dependency Dashboard creation.
    • Ignore node_modules, bower_components, vendor and various test/tests directories.
    • Automerge patch and minor upgrades if they pass tests.
    • If automerging, push the new commit directly to the base branch (no PR).
    • Wait for branch tests to pass or fail before creating the PR.
    • Rebase existing PRs any time the base branch has been updated.
    • Separate major versions of dependencies into individual branches/PRs.
    • Do not separate patch and minor upgrades into separate PRs for the same dependency.
    • Raise PR when vulnerability alerts are detected.
    • Evaluate schedules according to timezone UTC.
    • Append Signed-off-by: to signoff Git commits.
    • Apply label renovate to PRs.
    • Group all minor and patch updates together.
    • Default configuration for repositories in the Laminas organisation

    πŸ”‘ Would you like to change the way Renovate is upgrading your dependencies? Simply edit the renovate.json in this branch with your custom config and the list of Pull Requests in the "What to Expect" section below will be updated the next time Renovate runs.


    What to Expect

    With your current configuration, Renovate will create 4 Pull Requests:

    chore(deps): update actions/checkout action to v3
    • Schedule: ["at any time"]
    • Branch name: renovate/actions-checkout-3.x
    • Merge into: 3.8.x
    • Upgrade actions/checkout to v3
    chore(deps): update dependency laminas/laminas-coding-standard to v2
    chore(deps): update dependency psr/container to v2
    • Schedule: ["at any time"]
    • Branch name: renovate/psr-container-2.x
    • Merge into: 3.8.x
    • Upgrade psr/container to ^1.0 || ^2.0
    chore(deps): lock file maintenance
    • Schedule: ["before 2am"]
    • Branch name: renovate/lock-file-maintenance
    • Merge into: 3.8.x
    • Regenerate lock files to use latest dependency versions

    ❓ Got questions? Check out Renovate's Docs, particularly the Getting Started section. If you need any further assistance then you can also request help here.


    Read more information about the use of Renovate Bot within Laminas.

    renovate 
    opened by renovate[bot] 1
  • Psalm integration

    Psalm integration

    Feature Request

    | Q | A |------------ | ------ | QA | yes

    Summary

    As decided during the Technical-Steering-Committee Meeting on August 3rd, 2020, Laminas wants to implement vimeo/psalm in all packages.

    Implementing psalm is quite easy.

    Required

    • [ ] Create a psalm.xml in the project root
    • [ ] Copy and paste the contents from this psalm.xml.dist
    • [ ] Run $ composer require --dev vimeo/psalm
    • [ ] Run $ vendor/bin/psalm --set-baseline=psalm-baseline.xml
    • [ ] Add a composer script static-analysis with the command psalm --shepherd --stats
    • [ ] Add a new line to script: in .travis.yml: - if [[ $TEST_COVERAGE == 'true' ]]; then composer static-analysis ; fi
    • [ ] Remove phpstan from the project (phpstan.neon.dist, .travis.yml entry, composer.json require-dev and scripts)
    Optional
    • [ ] Fix as many psalm errors as possible.
    Enhancement Help Wanted hacktoberfest-accepted 
    opened by boesing 1
  • Ini scanner mode

    Ini scanner mode

    | Q | A |-------------- | ------ | Documentation | yes | Bugfix | no | BC Break | no | New Feature | yes | RFC | no | QA | yes

    Description

    Adds a typedMode flag to the INI Reader to support the built-in INI_SCANNER_TYPED flag on parse_ini_file(). This allows integer, boolean, and null values to be returned as the appropriate types, rather than all being returned as strings.

    Enhancement 
    opened by jcsanyi 1
  • Questions/thoughts regarding WriterInterface

    Questions/thoughts regarding WriterInterface

    I came to the following question/thoughts by chance, when I'v started implement a writer capable to write array configuration into multiple files. It splits configuration by criteria, currently hard-coded by key, later by strategy defined, into different files and join them in a stub-file, which includes the config from separate files.

    I use it for example in zfcampus/zf-configuration, to reduce the configuration file size and split top level keys into separate files. This way I can find things much quicker, if further module-separation is not possible/logical.

    Now everything works fine, but I'v noticed, that the API defined by WriterInterface does not make much sense in my new writer, because toString() would only return the stub-file contents.

    This made me think about two possibilities: Either my implementation of WriterInterface is misusing this interface and it is actually something else, that should internally use Writers, but is itself not a writer or the current spec for Writer in zend-config is to concrete.

    My conclusion so far is:

    • The job of my WriterInterface implementation is really to write the configuration, not something do something else. How it writers, in a single or multiple files, or even maybe not in a file, does not make it something else, than a writer.
    • Actually the current WriterInterface is rather something like a FileWriterInterface. A configuration should actually be writable to indefinite type of targets.

    Example how it seem logical to me, but if I'm wrong with my thought somewhere, correct me:

    interface WriterInterface
    {
        /**
         * Write configuration
         * 
         * @param mixed $config
         */
        public function write($config);
    }
    
    interface FileWriterInterface extends WriterInterface
    {
        /**
         * Write a config object to a file.
         *
         * @param  string  $filename
         * @param  mixed   $config
         * @param  bool $exclusiveLock
         * @return void
         */
        public function toFile($filename, $config, $exclusiveLock = true);
    
        /**
         * Write a config object to a string.
         *
         * @param  mixed $config
         * @return string
         */
        public function toString($config);
    }
    

    Whether Interfaces like the FileWriterInterface are actually needed then is another question. What do you think about it?


    Originally posted by @akomm at https://github.com/zendframework/zend-config/issues/7

    opened by weierophinney 1
  • What do you think about adding env processor for static files ?

    What do you think about adding env processor for static files ?

    • [x] I was not able to find an open or closed issue matching what I'm seeing.
    • [x] This is not a question. (Questions should be asked on chat (Signup here) or our forums.)

    Code to reproduce the issue

    # amqp.yaml
    # 
    amqp:
        host: 127.0.0.1
        port: 5672
        username: 'env(AMQP_USERNAME)'
        password: 'env(AMQP_PASSWORD)'
        vhost: /
    
    namespace Zend\Config\Processor;
    
    use Zend\Config\Config;
    use Zend\Config\Exception;
    use Zend\Config\Processor\Token;
    use Zend\Config\Processor\ProcessorInterface;
    
    class Env extends Token implements ProcessorInterface
    {
        protected function doProcess($value, array $replacements)
        {
            if (! is_string($value)) {
                return parent::doProcess($value, $replacements);
            }
    
            if (false === strpos($value, 'env(')) {
                return parent::doProcess($value, $replacements);
            }
    
            $value = $this->parseEnvRecursive($value);
    
            return $value;
        }
    
        /**
         * Parse env variables
         * 
         * @param mixed $input input
         * @return string
         */
        protected function parseEnvRecursive($input)
        {
            $regex = '/env\((.*?)\)/';
            if (is_array($input)) {
                $input = getenv($input[1]);
            }
            return preg_replace_callback($regex, array($this, 'parseEnvRecursive'), $input);
        }
    }
    
    require 'vendor/autoload.php';
    
    use Symfony\Component\Yaml\Yaml as SymfonyYaml;
    use Zend\Config\Config;
    use Zend\Config\Factory;
    use Zend\Config\Processor;
    use Zend\Config\Reader\Yaml as YamlConfig;
    
    Factory::registerReader('yaml', new YamlConfig([SymfonyYaml::class, 'parse']));
    
    putenv('AMQP_USERNAME=guest');
    
    $config = Factory::fromFile(dirname(__FILE__).'/config/amqp.yaml');
    
    $config = new Config($config, true);
    $processor = new Processor\Env();
    $processor->process($config);
    $config->setReadOnly();
    
    echo $config->amqp->username; // guest
    

    Expected results

    // guest


    Originally posted by @eguvenc at https://github.com/zendframework/zend-config/issues/50

    opened by weierophinney 1
  • Provide PHP 8.1 support

    Provide PHP 8.1 support

    This patch provides PHP 8.1 support, via the following changes:

    • Adds ~8.1.0 to the list of allowed PHP versions
    • Bumps laminas-stdlib minimum supported version to 3.6
    • Bumps PHPUnit to 9.5.5
    • Adds CI configuration to ignore platform PHP when installing under 8.1
    • Adds #[ReturnTypeWillChange] annotations to methods of Config implementing internal interfaces
    • Updates the unit test suite to work under PHPUnit 9.5
    Enhancement 
    opened by weierophinney 0
  • Merge release 3.5.1 into 3.6.x

    Merge release 3.5.1 into 3.6.x

    Release Notes for 3.5.1

    3.5.x bugfix release (patch)

    3.5.1

    • Total issues resolved: 0
    • Total pull requests resolved: 1
    • Total contributors: 1

    Bug

    Bug 
    opened by github-actions[bot] 0
  • Merge release 3.4.1 into 3.5.x

    Merge release 3.4.1 into 3.5.x

    opened by github-actions[bot] 0
Releases(3.8.0)
Owner
Laminas Project
Laminas components and MVC.
Laminas Project
run user analytics within your system and track user data inside your database.

WP Local Analytics plugin. run user analytics within your system and track user data inside your database. Installing Go to the plugin page from the W

Gary 5 Dec 21, 2022
WP Local Analytics plugin. - run user analytics within your system and track user data inside your database.

WP Local Analytics plugin. - run user analytics within your system and track user data inside your database.

Gary 5 Dec 21, 2022
Skosmos is a web-based tool providing services for accessing controlled vocabularies, which are used by indexers describing documents and searchers looking for suitable keywords.

Skosmos is a web-based tool providing services for accessing controlled vocabularies, which are used by indexers describing documents and searchers looking for suitable keywords.

National Library of Finland 195 Dec 24, 2022
A library for property-based policy evaluation

PropAuth: Property-based policy evaluation Performing evaluations on credentials for authentication or sets of permissions on users has its limitation

psec.io 59 Nov 29, 2021
This package provides a simple and intuitive way to work on the Youtube Data API. It provides fluent interface to Youtube features.

Laravel Youtube Client This package provides a simple and intuitive way to work on the Youtube Data API. It provides fluent interface to Youtube featu

Tilson Mateus 6 May 31, 2023
PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects.

?? Yell PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects. Requirement

Zeeshan Ahmad 20 Dec 8, 2018
Faker-driven, configuration-based, platform-agnostic, locale-compatible data faker tool

Masquerade Faker-driven, platform-agnostic, locale-compatible data faker tool Point Masquerade to a database, give it a rule-set defined in YAML and M

elgentos ecommerce solutions 219 Dec 13, 2022
Enables developers to modify Magento installations (configuration, data) based on the given environment using n98-magerun.

Enables developers to modify Magento installations (configuration, data) based on the given environment using n98-magerun.

LimeSoda Interactive Marketing GmbH 73 Apr 1, 2022
πŸ™ˆ Code style configuration for `php-cs-fixer` based on PSR-12.

php-code-style Code style configuration for friendsofphp/php-cs-fixer based on PSR-12. Installation Step 1 of 3 Install gomzyakov/php-code-style via c

Alexander Gomzyakov 5 Nov 27, 2022
PHP functions that help you validate structure of complex nested PHP arrays.

PHP functions that help you validate structure of complex nested PHP arrays.

cd rubin 7 May 22, 2022
Provides automatic recaching of product URLs within Prerender.io

magento2-prerender-io Provides integration between Magento 2 and Prerender.io, giving the ability for product pages to be automatically recached when

Aligent 2 Jun 28, 2022
An article about alternative solution for convert object into a JSON Object for your api.

Do we really need a serializer for our JSON API? The last years I did build a lot of JSON APIs but personally was never happy about the magic of using

Alexander Schranz 1 Feb 1, 2022
Your alter ego object. Takes the best of object and array worlds.

Supporting Opensource formapro\values is an MIT-licensed open source project with its ongoing development made possible entirely by the support of com

FormaPro 31 Jun 25, 2021
Preferences are configuration variables that are user-managed for which we cannot rely upon container parameters or environment variables.

Preferences Preferences are configuration variables that are meant to be user managed for which we cannot rely upon container parameters or environmen

Makina Corpus 1 Feb 7, 2022
KodExplorer is a file manager for web. It is also a web code editor, which allows you to develop websites directly within the web browser.

KodExplorer is a file manager for web. It is also a web code editor, which allows you to develop websites directly within the web browser.

warlee 5.5k Feb 10, 2022
Kirby 3 Plugin for running jobs like cleaning the cache from within the Panel, PHP code, CLI or a cronjob

Kirby 3 Janitor Kirby 3 Plugin for running jobs. It is a Panel Button! It has jobs build-in for cleaning the cache, sessions, create zip-backup, pre-g

Bruno Meilick 68 Dec 21, 2022
Strings Package provide a fluent, object-oriented interface for working with multibyte string

Strings Package provide a fluent, object-oriented interface for working with multibyte string, allowing you to chain multiple string operations together using a more readable syntax compared to traditional PHP strings functions.

Glowy PHP 14 Mar 12, 2022
Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

php-cs-fixer-config Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer. Installation Run $ composer require --dev e

null 37 Jan 2, 2023
Import/Export configuration data in Magento 2 via CLI.

ConfigImportExport This module provides new CLI commands for Magento 2 to import/export data in/from core_config_data. This module is inspired by the

semaio 135 Dec 9, 2022