### Install with Composer Source: https://github.com/jeffersongoncalves/laravel-zero-json-config/blob/main/README.md Install the package via Composer. Requires PHP 8.2 or later. ```bash composer require jeffersongoncalves/laravel-zero-json-config ``` -------------------------------- ### Basic JsonConfigService operations Source: https://github.com/jeffersongoncalves/laravel-zero-json-config/blob/main/README.md Basic usage of the JsonConfigService: set, get with fallback, has, all, forget, and path. The get method returns the fallback when a key is missing. ```php $config->set('token', 'secret'); $config->get('token'); // 'secret' $config->get('missing', 'fallback'); // 'fallback' $config->has('token'); // true $config->all(); // ['token' => 'secret'] $config->forget('token'); $config->path(); // absolute path of the JSON file ``` -------------------------------- ### Dot-notation usage for nested keys Source: https://github.com/jeffersongoncalves/laravel-zero-json-config/blob/main/README.md Dot-notation support: keys containing dots are treated as nested paths. When get is called, a flat top-level key matching the literal string is returned first if it exists; otherwise the key is split on '.' and resolved through the nested array. ```php $config->set('auth.token', 'xyz'); $config->get('auth'); // ['token' => 'xyz'] $config->get('auth.token'); // 'xyz' $config->forget('auth.token'); ``` -------------------------------- ### Instantiate JsonConfigService with GlobalScope, PerRepoScope, or PerProjectScope Source: https://github.com/jeffersongoncalves/laravel-zero-json-config/blob/main/README.md Create a JsonConfigService with one of three scope strategies. GlobalScope uses ~/.myapp/config.json, PerRepoScope uses ~/.config/myapp/owner-repo.json, and PerProjectScope uses ./myapp.json. The homeDir constructor argument on GlobalScope and PerRepoScope overrides the home directory; PerRepoScope also honors XDG_CONFIG_HOME. ```php use JeffersonGoncalves\LaravelZero\JsonConfig\JsonConfigService; use JeffersonGoncalves\LaravelZero\JsonConfig\Scopes\GlobalScope; use JeffersonGoncalves\LaravelZero\JsonConfig\Scopes\PerRepoScope; use JeffersonGoncalves\LaravelZero\JsonConfig\Scopes\PerProjectScope; // Global: ~/.myapp/config.json $config = new JsonConfigService(new GlobalScope('myapp')); // Per-repo: ~/.config/myapp/owner-repo.json (slug is caller-supplied) $config = new JsonConfigService(new PerRepoScope('myapp', 'owner-repo')); // Per-project: ./myapp.json (next to where you run the tool) $config = new JsonConfigService(new PerProjectScope(getcwd(), appName: 'myapp')); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.