PHPackages                             skywarth/laravel-config-mapper - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. skywarth/laravel-config-mapper

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

skywarth/laravel-config-mapper
==============================

Auto-mapper for configs, matching env keys

v1.3.4(3y ago)05GPL-3.0-or-laterPHP

Since Nov 19Pushed 3y ago2 watchersCompare

[ Source](https://github.com/skywarth/laravel-config-mapper)[ Packagist](https://packagist.org/packages/skywarth/laravel-config-mapper)[ RSS](/packages/skywarth-laravel-config-mapper/feed)WikiDiscussions master Synced today

READMEChangelog (5)Dependencies (2)Versions (10)Used By (0)

[![Code Coverage Badge](./badge.svg)](./badge.svg)

*Proof reading for the documentation is pending*

Laravel Config Mapper
=====================

[](#laravel-config-mapper)

Packagist:

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Problem Definition](#problem-definition)
    - [Example case](#example-case)
- [How to Use](#how-to-use)
    - [TL;DR](#how-to-use-tl-dr)
    - [Map the env keys by command](#map-env-keys-command)
        - [Just output the mapped env keys](#map-env-keys-command-just-output)
        - [Add mapped env keys to file](#map-env-keys-command-add-mapped-env-keys-to-file)
        - [Update configs and replace](#map-env-keys-command-update-config)
    - [Alternative Config Helper](#alternative-config-helper)
- [Roadmap &amp; TODOs](#roadmap-and-todos)
- [Credits &amp; References](#credits-and-references)

Laravel Config Mapper is a package for assisting your project with the ability to **automatically map configs with env keys**. It is designed for Laravel framework.

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

[](#-installation)

Run:

```
composer require skywarth/laravel-config-mapper

```

Optionally, you may publish the config, which allows you to tinker with libraries settings:

```
php artisan vendor:publish --provider="Skywarth\LaravelConfigMapper\LaravelConfigMapperServiceProvider" --tag="config"

```

 Problem Definition
-----------------------------------------------------------------

[](#-problem-definition)

You know the hassle... When defining a new configuration or adding to existing configuration, you have to give it a corresponding and appropriate env key. And if your config hierarchy has some depth, it is rather troublesome and prone to error. Laravel Config Mapper can help you eliminate this.

###  Example Case

[](#-example-case)

```
your-laravel-project/
├── config/
│   ├── filesystems.php
│   ├── app.php
│   ├── auth.php
│   ├── queue.php
│   ├── **tiger.php**
│   ├── mammals/
│   │   ├── panda.php
│   │   ├── dog.php
│   │   └── room/
│   │       └── elephant.php
│   └── non-mammals/
│       └── penguin
├── app
├── storage
├── public
├── .env
└── .env.example

```

*Example folder structure*

For the file structure above, assume you want to create configs for `tiger`, `panda`, `dog`, `elephant` and `penguin` (files are already created).

If we consider `elephant` in the `room` folder, and let's say we want elephant config to have `enabled`, and under `permissions` group `allowed_to_walk` and `allowed_to_sleep`. It would look something like this:

```
#./config/mammals/room/elephant.php
