The task of this package is to manage module dotnev-files used by the Laravel integration of phpdotenv.

Overview

Warning This Package is still work in progress!

Warning The package is basically functional, but there is no logic to handle the files in a repo.

Modular Monolith Laravel Env

The task of this package is to manage module dotnev-files used by the Laravel integration of phpdotenv. To store these files in source control without populating its contents to tjhe public the package is also based on Laravels environment encrypting by a shared secret. This way the package can also be used for forge or envoyer deployments.

Systemrequirements

  • This package is only tested with Laravel 9. So it requires "vlucas/phpdotenv": "^5.4.1".
  • The package is written in PHP 8.1.

Installation

To install you have to replace the Kernel-classes of Laravel.

app/Http/Kernel.php

// replace
5: use Illuminate\Foundation\Http\Kernel as HttpKernel;
// with
5: use RedFreak\ModularEnv\Foundation\Http\Kernel as HttpKernel;

app/Console/Kernel.php

// replace
6: use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
// with
6: use RedFreak\ModularEnv\Foundation\Console\Kernel as ConsoleKernel;

Testing

run in develope

./vendor/bin/phpunit

How to use

getting started

The package assumes that the including package is structured following the modular monolith talk with the additional dotenv-files by this logic:

.
├── app
├── .env
├── ...
├── src
│    ├── ModuleOne
│    │    ├── ...
│    │    └── .env
│    ├── ...
│    └── ModuleLast
│         ├── ...
│         └── .env
└── ...

If your structure is different you have to implement the ModularEnvironmentApplication-Contract into your application. By the method ModularEnvironmentApplication::additionalEnvFiles() the package will recognize different paths (* and ** are allowed and used like in the .gitignore).

using the variables

Variables form the default .env are accessed like before with the env()-helper.

Variables from the modules are accessed the same way with the difference that they are prefixed with the module name in SNAKE_CASE (caps) and __. E.g. the Variable HELLO=WORLD from the file /src/FooBar/.env can be accessed by env('FOO_BAR__HELLO').

tasks

tasks for 0.3.0 - encrypting the files

  • support for env:encrypt and env:decrypt to handle the files
  • implementing modular_env:encrypt and modular_env:deecrypt to support deployment processes

1.0.0-alpha

  • maybe writing additional tests
  • adding a test-pipeline for gitHub
  • fixing and testing of 0.3.0 in real-life-environments

1.0.0 - MVP

  • fixed release of 1.0.0-alpha

1.1.0 - LaravelRay

  • support for LaravelRay

recommendations

use the following in your .gitignore

.env
.env.*
!.env.example
!.env*.encrypted
!.env.pipelines
/src/**/.env
/src/**/.env.*
!/src/**/.env*.encrypted
!/src/**/.env.example

Why do I?

Why do I have to replace Kernel-Classes?

I see, replacing the Kernel is a big issue. But .env-files are bootstrapped before anything else, so we have to hook something before everything else. The Kernels are present and inheriting, so it's a good point to hook in.

Need to create my own Application class?

You don't have to it's just a possibility to determine a custom path-structure on your dotenv-files. The default "setting" will be to guess files in /src/**/.

Need to create my own Application class if I have a custom path-structure on my .env-files?

The problem for this package is, that we want to hook a behaviour which is deep in the functionality of Laravel. At the moment the dotenv-files are loaded there is just a "stub" of the Application, there is no way to use config or env. So this seemed the best option to not produce unnecessary disk-requests. This is especially important for applications handling hundreds of requests per second.

Licence

This package is free to use as stated by the LICENCE.md under the MIT License, but you can buy me a coffee if you want :D.

You might also like...
ICSGenerator - The module can generate basic ICS calendar strings and files

ICSGenerator The module can generate basic ICS calendar strings and files. The module simply extends WireData. It has these properties and default val

Perch Dashboard app for exporting content to (Kirby) text files and Kirby Blueprint files
Perch Dashboard app for exporting content to (Kirby) text files and Kirby Blueprint files

toKirby Perch Dashboard app for exporting content to (Kirby) text files and Kirby Blueprint files. You can easily install and test it in a few steps.

An online system to keep digitized form of employee personal files (staff personal files)

An online system to keep digitized form of employee personal files (staff personal files).

Provide CSV, JSON, XML and YAML files as an Import Source for the Icinga Director and optionally ship hand-crafted additional Icinga2 config files
Provide CSV, JSON, XML and YAML files as an Import Source for the Icinga Director and optionally ship hand-crafted additional Icinga2 config files

Icinga Web 2 Fileshipper module The main purpose of this module is to extend Icinga Director using some of it's exported hooks. Based on them it offer

Laravel Podcast Manager is a complete podcast manager package for Laravel 5.3+ that enables you to manage RSS feeds for your favorite podcasts and listen to the episodes in a seamless UI.
Laravel Podcast Manager is a complete podcast manager package for Laravel 5.3+ that enables you to manage RSS feeds for your favorite podcasts and listen to the episodes in a seamless UI.

laravelpodcast | A Laravel podcast manager package - v0.0.8 Introduction Laravel Podcast Manager is a complete podcast manager package for Laravel 5.3

This package is the Laravel Nova integration for justbetter/laravel-magento-prices

Laravel Magento Products Nova This package is the Laravel Nova integration for justbetter/laravel-magento-products. Installation Install the package.

uPay(bangladesh) payment gateway integration package for laravel

uPay BD Payment Gateway Requirements PHP =7.2 Laravel = 6 Installation composer require codeboxr/upay vendor publish (config) php artisan vendor:pub

This package is used to validate the telephone numbers of the countries taken into account. It also makes it possible to verify that a number is indeed a number of an operator X

phone-number-checker This package is used to validate the telephone numbers of the countries taken into account. It also makes it possible to verify t

A simple and easy-to-use enumeration extension package to help you manage enumerations in your project more conveniently

A simple and easy-to-use enumeration extension package to help you manage enumerations in your project more conveniently

Releases(0.2.1)
Owner
RedFreak_
RedFreak_
This package provides a set of factories to be used with containers using the PSR-11 standard for an easy Doctrine integration in a project

psr-container-doctrine: Doctrine Factories for PSR-11 Containers Doctrine factories for PSR-11 containers. This package provides a set of factories to

Roave, LLC 84 Dec 14, 2022
Adds factory functions for WooCommerce to be used with wp-browser integration tests.

wp-browser-woocommerce This library simplifies testing of WooCommerce themes and plugins with wp-browser. Several Unit Test Factories are added that a

Level Level 12 Dec 29, 2022
Magento 2 Module Experius Page Not Found 404. This module saves all 404 url to a database table

Magento 2 Module Experius Page Not Found 404 This module saves all 404 urls to a database table. Adds an admin grid with 404s It includes a count so y

Experius 28 Dec 9, 2022
This tool is used to build and maintain browscap files.

Browser Capabilities Project This tool is used to build and maintain browscap files.

Browser Capabilities Project 400 Dec 29, 2022
A wrapper around symplify/config-transformer used to update recipes and using easy coding standard for generating readable config files.

Symfony Recipes Yaml to PHP Converter This is a wrapper around the symplify/config-transformer used to convert Symfony core recipes which uses .yaml c

Alexander Schranz 3 Nov 24, 2022
Task for GrumPHP that adds CSS linting support with stylelint. An easy way to enforce convention and avoid errors in your styles

grumphp-stylelint-task Installation Stylelint is a static analysis tool for styles. A mighty, modern linter that helps you avoid errors and enforce co

null 3 Apr 29, 2021
SilverStripe Model Annotations Task

A SilverStripe Task to generate data object model annotations for defined db fields. Also for configs from data extensions.

CSoellinger 2 Apr 21, 2022
A complete solution for group projects in organizations that lets you track your work in any scenario. Working in a team is a cumbersome task, ease it using our project management system.

SE-Project-Group24 What is Evolo? Evolo is Dashboard based Project Management System. A complete solution for group projects in organizations that let

Devanshi Savla 2 Oct 7, 2022
Traits used primarily in the v6 package but also available as a helper package for applications

Phalcon Traits This package contains traits with methods that are used for Phalcon v6 onward. It can also be useful to others that want short snippets

The Phalcon PHP Framework 5 Oct 7, 2022
Magento 2 Module for parsing xlsx, xlsm and csv files from Excel

Magento 2 Spreadsheet Parser Facts Parse XLSX, XLSM and CSV Files from Excel Requirements PHP >= 7.0.* Magento >= 2.1.* Compatibility Magento >= 2.1 U

Stämpfli AG 9 Sep 24, 2020