Weave Code
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

Zend Config Laravel Package

zendframework/zend-config

zendframework/zend-config provides configuration management for PHP apps: load settings from multiple formats (PHP arrays, INI, JSON, XML, YAML), merge/override environments, and access values via a simple object/array API. Part of the Zend Framework component set.

View on GitHub
Deep Wiki
Context7

Introduction

zend-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 formats supporting hierarchical data storage. Currently, zend-config provides adapters that read and write configuration data stored in INI, JSON, YAML, and XML files.

Using Reader Classes

Normally, users will use one of the reader classes to read a configuration file, but if configuration data is available in a PHP array, one may simply pass the data to Zend\Config\Config's constructor in order to utilize a simple object-oriented interface:

// An array of configuration data is given
$configArray = [
    'webhost'  => 'www.example.com',
    'database' => [
        'adapter' => 'pdo_mysql',
        'params'  => [
            'host'     => 'db.example.com',
            'username' => 'dbuser',
            'password' => 'secret',
            'dbname'   => 'mydatabase',
        ],
    ],
];

// Create the object-oriented wrapper using the configuration data
$config = new Zend\Config\Config($configArray);

// Print a configuration datum (results in 'www.example.com')
echo $config->webhost;

As illustrated in the example above, Zend\Config\Config provides nested object property syntax to access configuration data passed to its constructor.

Along with the object-oriented access to the data values, Zend\Config\Config also has a get() method that accepts a default value to return if the data element requested doesn't exist in the configuration array. For example:

$host = $config->database->get('host', 'localhost');

Using PHP Configuration Files

PHP-based configuration files are often recommended due to the speed with which they are parsed, and the fact that they can be cached by opcode caches.

The following code illustrates how to use PHP configuration files:

// config.php
return [
    'webhost'  => 'www.example.com',
    'database' => [
        'adapter' => 'pdo_mysql',
        'params'  => [
            'host'     => 'db.example.com',
            'username' => 'dbuser',
            'password' => 'secret',
            'dbname'   => 'mydatabase',
        ],
    ],
];
// Consumes the configuration array
$config = new Zend\Config\Config(include 'config.php');

// Print a configuration datum (results in 'www.example.com')
echo $config->webhost;
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport