PHP code example of winter / laravel-config-writer

1. Go to this page and download the library: Download winter/laravel-config-writer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

winter / laravel-config-writer example snippets


use Winter\LaravelConfigWriter\ArrayFile;

$config = ArrayFile::open(base_path('config/app.php'));

$config->set('name', 'Winter CMS');

$config
    ->set('locale', 'en_US')
    ->set('fallbackLocale', 'en');

$config->set([
    'trustedHosts' => true,
    'trustedProxies' => '*',
]);

$config->set('connections.mysql.host', 'localhost');

$config->set([
    'connections' => [
        'sqlite' => [
            'database' => 'database.sqlite',
            'driver' => 'sqlite',
            'foreign_key_constraints' => true,
            'prefix' => '',
            'url' => null,
        ],
    ],
]);

$config->write();

$config->write('path/to/newfile.php');

$config->render();

$config->set('name', $config->function('env', ['APP_NAME', 'Winter CMS']));

$config->set('foo.bar', $config->constant('My\Class::CONSTANT'));

$config->sort();

$config->sort(ArrayFile::SORT_DESC);

use Winter\LaravelConfigWriter\EnvFile;

$env = EnvFile::open(base_path('.env'));

$env->set('APP_NAME', 'Winter CMS');

$env
    ->set('APP_URL', 'https://wintercms.com')
    ->set('APP_ENV', 'production');

$env->set([
    'DB_CONNECTION' => 'sqlite',
    'DB_DATABASE' => 'database.sqlite',
]);

$env->set('FOO', 'bar');
$env->addEmptyLine();
$env->set('BAR', 'foo');

$env->write();

$env->write(base_path('.env.local'));

$env->render();