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

The Factory

Zend\Config\Factory provides the ability to load configuration files to an array or to a Zend\Config\Config object. The factory has two purposes

  • Loading configuration file(s)
  • Storing a configuration file

Storage writes to a single file

Storing the configuration always writes to a single file. The factory is not aware of merged configuration files, and as such cannot split configuration to multiple files. If you want to store particular configuration sections to separate files, you should separate them manually.

Loading configuration files

The first example illustrates loading a single configuration file:

// Load a PHP file as array:
$config = Zend\Config\Factory::fromFile(__DIR__ . '/config/my.config.php');

// Load an XML file as Config object; the second parameter, when true,
// casts the configuration to a Config instance:
$config = Zend\Config\Factory::fromFile(__DIR__.'/config/my.config.xml', true);

The next example demonstrates merging multiple files; note that they are in separate formats!

$config = Zend\Config\Factory::fromFiles([
    __DIR__.'/config/my.config.php',
    __DIR__.'/config/my.config.xml',
]);

Storing configuration

Sometimes you may want to write configuration to a file. To do this, use the factory's toFile() method:

$config = new Zend\Config\Config([], true);
$config->settings = [];
$config->settings->myname = 'framework';
$config->settings->date   = '2012-12-12 12:12:12';

//Store the configuration
Zend\Config\Factory::toFile(__DIR__ . '/config/my.config.php', $config);

//Store an array
$config = [
    'settings' => [
        'myname' => 'framework',
        'data'   => '2012-12-12 12:12:12',
    ],
];

Zend\Config\Factory::toFile(__DIR__ . '/config/my.config.php', $config);
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