PHPackages                             jeffersongoncalves/laravel-zero-json-config - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. jeffersongoncalves/laravel-zero-json-config

ActiveLibrary[CLI &amp; Console](/categories/cli)

jeffersongoncalves/laravel-zero-json-config
===========================================

Base JSON configuration service for CLIs, with scope strategies (global, per-repo, per-project), get/set/all and 0600 writes.

v1.0.0(today)10MITPHPPHP ^8.2CI passing

Since Jun 23Pushed today1 watchersCompare

[ Source](https://github.com/jeffersongoncalves/laravel-zero-json-config)[ Packagist](https://packagist.org/packages/jeffersongoncalves/laravel-zero-json-config)[ Docs](https://github.com/jeffersongoncalves/laravel-zero-json-config)[ RSS](/packages/jeffersongoncalves-laravel-zero-json-config/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

[![laravel-zero-json-config](https://raw.githubusercontent.com/jeffersongoncalves/laravel-zero-json-config/main/art/jeffersongoncalves-laravel-zero-json-config.png)](https://raw.githubusercontent.com/jeffersongoncalves/laravel-zero-json-config/main/art/jeffersongoncalves-laravel-zero-json-config.png)

laravel-zero-json-config
========================

[](#laravel-zero-json-config)

A tiny, self-contained JSON configuration service for PHP CLI tools (built with Laravel Zero in mind, but framework-free). It separates **where** a config file lives (the *scope*) from **how** values are read and written (the *service*), so you can swap a global config for a per-repo or per-project one without touching call sites.

- No runtime dependencies (only `php: ^8.2`).
- Three ready-made scope strategies.
- `get` / `set` / `all` / `has` / `forget` with **dot-notation** support.
- Safe writes: pretty JSON, file mode `0600`, parent dir `0700`.

Installation
------------

[](#installation)

```
composer require jeffersongoncalves/laravel-zero-json-config
```

Scopes
------

[](#scopes)

A scope implements `ConfigScope` and answers one question: `path(): string`, the absolute path of the JSON file.

ScopePathUse case`GlobalScope``~/./config.json`One machine-wide config per app`PerRepoScope``${XDG_CONFIG_HOME:-~/.config}//.json`One config per repository`PerProjectScope``/` (default `/.json`)Config committed next to the project```
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'));
```

The `homeDir` constructor argument on `GlobalScope` / `PerRepoScope` lets you override the home directory (useful for tests). `PerRepoScope` also honors the `XDG_CONFIG_HOME` environment variable.

Usage
-----

[](#usage)

```
$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

[](#dot-notation)

Keys containing a dot are treated as nested paths:

```
$config->set('auth.token', 'xyz');
$config->get('auth');        // ['token' => 'xyz']
$config->get('auth.token');  // 'xyz'
$config->forget('auth.token');
```

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.

Public API
----------

[](#public-api)

- `JeffersonGoncalves\LaravelZero\JsonConfig\ConfigScope` (interface) — `path(): string`
- `JeffersonGoncalves\LaravelZero\JsonConfig\JsonConfigService` — `get`, `set`, `all`, `has`, `forget`, `path`
- `JeffersonGoncalves\LaravelZero\JsonConfig\Scopes\GlobalScope`
- `JeffersonGoncalves\LaravelZero\JsonConfig\Scopes\PerRepoScope`
- `JeffersonGoncalves\LaravelZero\JsonConfig\Scopes\PerProjectScope`

License
-------

[](#license)

MIT

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance100

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/411493?v=4)[Jefferson Gonçalves](/maintainers/jeffersongoncalves)[@jeffersongoncalves](https://github.com/jeffersongoncalves)

---

Top Contributors

[![jeffersongoncalves](https://avatars.githubusercontent.com/u/411493?v=4)](https://github.com/jeffersongoncalves "jeffersongoncalves (3 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

clicomposerconfigconfigurationjeffersongoncalvesjsonlaravel-zerophpjsoncliconfigurationconfiglaravel-zero

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/jeffersongoncalves-laravel-zero-json-config/health.svg)

```
[![Health](https://phpackages.com/badges/jeffersongoncalves-laravel-zero-json-config/health.svg)](https://phpackages.com/packages/jeffersongoncalves-laravel-zero-json-config)
```

###  Alternatives

[nunomaduro/collision

Cli error handling for console/command-line PHP applications.

4.6k348.7M10.4k](/packages/nunomaduro-collision)[nunomaduro/laravel-console-menu

Laravel Console Menu is an output method for your Laravel/Laravel Zero commands.

815424.6k52](/packages/nunomaduro-laravel-console-menu)[nunomaduro/laravel-console-task

Laravel Console Task is a output method for your Laravel/Laravel Zero commands.

2592.3M13](/packages/nunomaduro-laravel-console-task)[nunomaduro/laravel-console-summary

A Beautiful Laravel Console Summary for your Laravel/Laravel Zero commands.

672.2M4](/packages/nunomaduro-laravel-console-summary)[nunomaduro/laravel-console-dusk

Laravel Console Dusk allows the usage of Laravel Dusk in Laravel/Laravel Zero artisan commands.

16357.3k8](/packages/nunomaduro-laravel-console-dusk)[mehrancodes/laravel-harbor

A CLI tool to Quickly create On-Demand preview environment for your apps.

10095.6k](/packages/mehrancodes-laravel-harbor)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
