PHPackages                             ibrostudio/laravel-neon-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. ibrostudio/laravel-neon-config

ActiveLibrary

ibrostudio/laravel-neon-config
==============================

Add Neon config values to Laravel config'

1.3.0(10mo ago)0211MITPHPPHP ^8.3

Since Sep 25Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/iBroStudio/laravel-neon-config)[ Packagist](https://packagist.org/packages/ibrostudio/laravel-neon-config)[ Docs](https://github.com/ibrostudio/laravel-neon-config)[ RSS](/packages/ibrostudio-laravel-neon-config/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (14)Versions (5)Used By (1)

Laravel Neon Config
===================

[](#laravel-neon-config)

[![Latest Version on Packagist](https://camo.githubusercontent.com/cf9230e87ff674aa88d7bb68f76f545b8a5c8c50dea5cd3ee3298c8c4c80688b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6962726f73747564696f2f6c61726176656c2d6e656f6e2d636f6e6669672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ibrostudio/laravel-neon-config)

Introduction
------------

[](#introduction)

Laravel Neon Config is a package that integrates [Neon](https://github.com/nette/neon) configuration files with Laravel's config system. Neon is a human-friendly data serialization language similar to YAML but with a focus on being more readable and concise.

### What is Neon?

[](#what-is-neon)

Neon (Nette Object Notation) is a human-readable structured data format. It is similar to YAML but is more focused on being concise and readable. Neon is developed by the Nette Foundation and is used extensively in Nette Framework applications.

### Goal of this Package

[](#goal-of-this-package)

The primary goal of this package is to provide a configuration mechanism that works outside the context of a Laravel application. This is particularly useful in scenarios such as:

- When developing a package that is used as a dev dependency of another package
- When you need an environment file for tests while developing a package
- When you want to allow users of your package to easily override configuration values without modifying your package's files

**This package allows you to use a .neon file to overwrite a Laravel config file.**

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

[](#installation)

You can install the package via composer:

```
composer require ibrostudio/laravel-neon-config
```

Basic Usage
-----------

[](#basic-usage)

### In a Package Service Provider

[](#in-a-package-service-provider)

Add the trait `UseNeonConfig` to your package service provider and define your "neon to config" mapping:

```
use IBroStudio\NeonConfig\Concerns\UseNeonConfig;

class PackageServiceProvider extends ServiceProvider
{
    use UseNeonConfig;

    public function register()
    {
        $this->handleNeon('package-neon-file')->forConfig('package-config-key');
    }
}
```

### With Spatie's Package Skeleton

[](#with-spaties-package-skeleton)

If your package uses **PackageServiceProvider** from Spatie's [package-skeleton-laravel](https://github.com/spatie/package-skeleton-laravel) and you are only dealing with a single config file, you can omit the name parameters:

```
use IBroStudio\NeonConfig\Concerns\UseNeonConfig;

class PackageServiceProvider extends PackageServiceProvider
{
    use UseNeonConfig;

    public function packageRegistered(): void
    {
        $this->handleNeon()->forConfig();
    }
}
```

### How It Works

[](#how-it-works)

When a user of your package creates a .neon file at the root of their project with the same name as your package, the values from that file will be merged with your package's configuration.

For example, if your package has this configuration:

```
// config/your-package.php
return [
    'key1' => 'value1',
    'key2' => 'value2',
    'array' => [
        'array_key1' => 'array_value1',
        'array_key2' => 'array_value2',
    ],
];
```

The user can create a file named `your-package.neon` at the root of their project:

```
key1: new value
array:
    - new_array_key: new_value
    - array_key2: new_array_value
```

**Values are merged by keys, which means:**

- Values with the same keys are replaced
- Omitted keys are kept
- New keys are added

Advanced Features
-----------------

[](#advanced-features)

### Casting and Dynamic Values

[](#casting-and-dynamic-values)

#### Enums

[](#enums)

If your config uses PHP Enums, you can cast values from the Neon file to the appropriate enum type:

```
// config/your-package.php
return [
    'key1' => SomeEnumClass::VALUE,
];
```

At the root of your package, create a file named `neon-config.neon`:

```
casts:
    - key1: \Namespace\SomeEnumClass
```

Then, the user can override the enum value in their Neon file:

```
key1: newValue
```

Now, calling `config('your-package.key1')` will return an instance of `\Namespace\SomeEnumClass::NEW_VALUE`.

#### Array of Enums

[](#array-of-enums)

You can also cast arrays of values to arrays of enum instances:

```
// config/your-package.php
return [
    'key1' => [
        SomeEnumClass::VALUE1,
        SomeEnumClass::VALUE2,
        SomeEnumClass::VALUE3,
    ],
];
```

In your `neon-config.neon`:

```
casts:
    - key1: AsEnumCollection::\Namespace\SomeEnumClass
```

And in the user's Neon file:

```
key1:
    - value4
    - value5
    - value6
```

#### Dynamic Values from Config or Environment

[](#dynamic-values-from-config-or-environment)

You can also reference other config values or environment variables:

```
// config/your-package.php
return [
    'key1' => config('some.config', 'default value'),
    'key2' => env('MY_ENV_VAR', 'default value'),
];
```

In your `neon-config.neon`:

```
casts:
    - key1: AsConfig::some.config
    - key2: AsEnv::MY_ENV_VAR
```

And in the user's Neon file:

```
key1: other.config.key(type: config, default: 'other default value')
key2: OTHER_ENV(type: env)
```

Using as an Environment File for Tests
--------------------------------------

[](#using-as-an-environment-file-for-tests)

When developing a package, you can use Neon files as environment files for your tests:

### Configuration

[](#configuration)

Add the trait to your TestCase instead of the package service provider:

```
use IBroStudio\NeonConfig\Concerns\UseNeonConfig;

class TestCase extends Orchestra
{
    use UseNeonConfig;

    public function getEnvironmentSetUp($app)
    {
        $this->handleNeon('test')->forConfig('test');
    }
}
```

Create a `test.neon` file at the root of your package (add it to .gitignore):

```
key1: test-value-1
key2: test-value-2
```

During tests, you can now access these values with `config('test.key1')`.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [iBroStudio](https://github.com/ibrostudio)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance54

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Every ~92 days

Total

4

Last Release

319d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3a456dae716df4be38cb7d5f02ca522a02ec37eda586ab0cae0f504516b7c1ef?d=identicon)[iBroStudio](/maintainers/iBroStudio)

---

Top Contributors

[![Yann-iBroStudio](https://avatars.githubusercontent.com/u/2676572?v=4)](https://github.com/Yann-iBroStudio "Yann-iBroStudio (9 commits)")

---

Tags

laravelconfigpackageneoniBroStudio

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/ibrostudio-laravel-neon-config/health.svg)

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

###  Alternatives

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[danestves/laravel-polar

A package to easily integrate your Laravel application with Polar.sh

7812.3k](/packages/danestves-laravel-polar)[tarfin-labs/event-machine

Event-driven state machines for Laravel with event sourcing, type-safe context, and full audit trail.

188.5k](/packages/tarfin-labs-event-machine)[basillangevin/laravel-data-json-schemas

Transforms Spatie Data objects into JSON Schemas with built-in validation

1312.2k1](/packages/basillangevin-laravel-data-json-schemas)[a2insights/filament-saas

Filament Saas for A2Insights

161.1k](/packages/a2insights-filament-saas)

PHPackages © 2026

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