All Projects → sroze → Companienv

sroze / Companienv

Licence: mit
Companion for .env files

Projects that are alternatives of or similar to Companienv

Schema Generator
PHP Model Scaffolding from Schema.org and other RDF vocabularies
Stars: ✭ 379 (+57.26%)
Mutual labels:  symfony, generator
Easyadminbundle
EasyAdmin is a fast, beautiful and modern admin generator for Symfony applications.
Stars: ✭ 3,391 (+1307.05%)
Mutual labels:  symfony, generator
Dotenv
Symfony Dotenv parses .env files to make environment variables stored in them accessible via getenv(), $_ENV, or $_SERVER.
Stars: ✭ 3,268 (+1256.02%)
Mutual labels:  dotenv, symfony
Easy Doc Bundle
Symfony application documentation generator
Stars: ✭ 99 (-58.92%)
Mutual labels:  symfony, generator
Anydlbot
An Open Source GPLv3 All-In-One Telegram Bot
Stars: ✭ 236 (-2.07%)
Mutual labels:  generator
Asset
The Asset component manages URL generation and versioning of web assets such as CSS stylesheets, JavaScript files and image files.
Stars: ✭ 2,771 (+1049.79%)
Mutual labels:  symfony
Fmelfinderbundle
📁 ElFinderBundle provides ElFinder integration with TinyMCE, CKEditor, Summernote editors
Stars: ✭ 231 (-4.15%)
Mutual labels:  symfony
Victoire
Fullstack Symfony CMS: The perfect mix between a framework and a CMS
Stars: ✭ 227 (-5.81%)
Mutual labels:  symfony
Gallery
Visual Portfolio Generator with no extra installation
Stars: ✭ 239 (-0.83%)
Mutual labels:  generator
Sonata Doctrine Extensions
Doctrine2 behavioral extensions
Stars: ✭ 239 (-0.83%)
Mutual labels:  symfony
Htmlpurifierbundle
HTML Purifier is a standards-compliant HTML filter library written in PHP.
Stars: ✭ 234 (-2.9%)
Mutual labels:  symfony
Dtsmake
TypeScript 's type definition file (*.d.ts files) generator tool from JavaScript files.
Stars: ✭ 231 (-4.15%)
Mutual labels:  generator
Reverse Shell Generator
Hosted Reverse Shell generator with a ton of functionality. -- (Great for CTFs)
Stars: ✭ 238 (-1.24%)
Mutual labels:  generator
Easyadminextensionbundle
Provides some additional features to EasyAdminBundle for Symfony
Stars: ✭ 232 (-3.73%)
Mutual labels:  symfony
Extension Create
Create modern cross-browser extensions with no build configuration.
Stars: ✭ 167 (-30.71%)
Mutual labels:  generator
Alicedatafixtures
Nelmio Alice extension to persist the loaded fixtures.
Stars: ✭ 228 (-5.39%)
Mutual labels:  symfony
Options Resolver
The OptionsResolver component is array_replace() on steroids. It allows you to create an options system with required options, defaults, validation (type, value), normalization and more.
Stars: ✭ 2,723 (+1029.88%)
Mutual labels:  symfony
Generate
A new command line tool and developer framework for scaffolding out GitHub projects. Generate offers the robustness and configurability of Yeoman, the expressiveness and simplicity of Slush, and more powerful flow control and composability than either.
Stars: ✭ 238 (-1.24%)
Mutual labels:  generator
Enqueue Bundle
[READ-ONLY] Message queue bundle for Symfony. RabbitMQ, Amazon SQS, Redis, Service bus, Async events, RPC over MQ and a lot more
Stars: ✭ 233 (-3.32%)
Mutual labels:  symfony
Create Exposed App
App generator with everything exposed for maximum control (powered by TypeScript, ESBuild, Jest, ESLint, GitHub Actions, Prettier, and more)
Stars: ✭ 232 (-3.73%)
Mutual labels:  generator

Companienv

Your companion for .env files. Everybody knows about 12 factor and environments variables now. A lot of frameworks such as Symfony are using a .env file to configure the application, but we don't have anything to help users to complete their local .env file.

Companienv will helps you manage the .env files, from a reference .env.dist version in your code repository. Companienv can:

Usage

  1. Require sroze/companienv as your project dependency:
composer req sroze/companienv
  1. Run your companion:
vendor/bin/companienv

Composer automation

You can run Companienv automatically after composer install or composer update commands by configuring the scripts in your composer.json file:

{
    "scripts": {
        "post-install-cmd": [
            "Companienv\\Composer\\ScriptHandler::run"
        ],
        "post-update-cmd": [
            "Companienv\\Composer\\ScriptHandler::run"
        ]
    }
}

By default, the file used as a template is .env.dist and the written file is .env. You can change these defaults within your composer.json file:

{
    "extra": {
        "companienv-parameters": [
            {
                "file": ".env.foo",
                "dist-file": ".env.foo.dist"
            }
        ]
    }
}

The .env.dist file

All your configuration is directly in your .env.dist file, as comments. The configuration is divided in blocks that will be displayed to the user for a greater understanding of the configuration. Here are the fondations for Companienv:

  • Blocks. They logically group variables together. They are defined by a title (line starting with a double-comment ##) and a description (every comment line directly bellow)
  • Attributes. Defined by a line starting with #+, an attribute is associated to one or multiple variables. These attributes are the entrypoint for extensions. In the example above, it says that the JWT_* variables are associated with an RSA key pair, so Companienv will automatically offer the user to generate one for them.
  • Comments. Lines starting by #~ will be ignored by Companienv.

Example of .env.dist. file

# .env.dist

## Welcome in the configuration of [my-project]
#
#~ Please run the `bin/start` command.
#~ These lines starting with `~` are not going to be displayed to the user

## GitHub
# In order to be able to login with GitHub, you need to create a GitHub application. To get access to the code
# repositories, you need to create a GitHub integration.
#
#+file-to-propagate(GITHUB_INTEGRATION_KEY_PATH)
#
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_INTEGRATION_ID=
GITHUB_INTEGRATION_KEY_PATH=
GITHUB_SECRET=

## Security
# We need sauce! Well, no, we need an SSL certificate.
#
#+rsa-pair(JWT_PRIVATE_KEY_PATH JWT_PUBLIC_KEY_PATH JWT_PRIVATE_KEY_PASS_PHRASE)
#
JWT_PRIVATE_KEY_PATH=/runtime/keys/jwt-private.pem
JWT_PUBLIC_KEY_PATH=/runtime/keys/jwt-public.pem
JWT_PRIVATE_KEY_PASS_PHRASE=

## Another block
# With its (optional) description
AND_OTHER_VARIABLES=

Built-in extensions

only-if extension

Some of the blocks of your .env file might not even be relevant if some other variable was disabling a given feature.

Example: This will only ask for the INTERCOM_APPLICATION_ID variable if INTERCOM_ENABLED has the value (current or entered by the user) true.

## Support & Feedback
# If you would like to allow your users to get some support from you, give you some feedback and this
# sort of things, select the integrations you'd like.
#
#+only-if(INTERCOM_APPLICATION_ID):(INTERCOM_ENABLED=true)
#
INTERCOM_ENABLED=false
INTERCOM_APPLICATION_ID=none

file-to-propagate extension

Will ask the path of an existing file and copy it to the destination mentioned in the reference.

Example: this will ask the user to give the path of an existing file. It will copy this file to the path /runtime/keys/firebase.json, relative to the root directory of the project.

#+file-to-propagate(FIREBASE_SERVICE_ACCOUNT_PATH)
FIREBASE_SERVICE_ACCOUNT_PATH=/runtime/keys/firebase.json

rsa-pair extension

If the public/private key pair does not exist, Companienv will offer to generate one for the user.

#+rsa-pair(JWT_PRIVATE_KEY_PATH JWT_PUBLIC_KEY_PATH JWT_PRIVATE_KEY_PASS_PHRASE)
JWT_PRIVATE_KEY_PATH=/runtime/keys/jwt-private.pem
JWT_PUBLIC_KEY_PATH=/runtime/keys/jwt-public.pem
JWT_PRIVATE_KEY_PASS_PHRASE=

ssl-certificate-extension

Similar to the RSA keys pair: Companienv will offer to generate a self-signed SSL certificate if it does not exist yet.

#+ssl-certificate(SSL_CERTIFICATE_PRIVATE_KEY_PATH SSL_CERTIFICATE_CERTIFICATE_PATH SSL_CERTIFICATE_DOMAIN_NAME)
SSL_CERTIFICATE_PRIVATE_KEY_PATH=/runtime/keys/server.key
SSL_CERTIFICATE_CERTIFICATE_PATH=/runtime/keys/server.crt
SSL_CERTIFICATE_DOMAIN_NAME=

Your own extensions

You can easily create and use your own extensions with Companienv. In order to do so, you'll have to start Companienv with your own PHP file and use the registerExtension method of the Application:

use Companienv\Application;
use Companienv\Extension;

$application = new Application($rootDirectory);
$application->registerExtension(new class() implements Extension {
    // Implements the interface...
});
$application->run();
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].