PHP code example of ibrostudio / laravel-neon-config

1. Go to this page and download the library: Download ibrostudio/laravel-neon-config 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/ */

    

ibrostudio / laravel-neon-config example snippets


use IBroStudio\NeonConfig\Concerns\UseNeonConfig;

class PackageServiceProvider extends ServiceProvider
{
    use UseNeonConfig;
    
    public function register()
    {
        $this->handleNeon('package-neon-file')->forConfig('package-config-key');
    }
...

use IBroStudio\NeonConfig\Concerns\UseNeonConfig;

class PackageServiceProvider extends PackageServiceProvider
{
    use UseNeonConfig;
    
    public function packageRegistered(): void
    {
        $this->handleNeon()->forConfig();
    }
...

return [
    'key1' => 'value1',
    'key2' => 'value2',
    'array' => [
        'array_key1' => 'array_value1',
        'array_key2' => 'array_value2',
    ],
];

return [
    'key1' => SomeEnumClass::VALUE,
];

return [
    'key1' => [
        SomeEnumClass::VALUE1,
        SomeEnumClass::VALUE2,
        SomeEnumClass::VALUE3,
    ],
];

return [
    'key1' => config('some.config', 'default value'),
    'key2' => env('MY_ENV_VAR', 'default value' ),
];
neon
key1: new value
array:
    - new_array_key: new_value
    - array_key2: array_value