Giter VIP home page Giter VIP logo

kirby-env's Introduction

Kirby Env

Latest Stable Version GitHub Workflow Status Total Downloads License

Kirby Env use the vlucas/phpdotenv package and enable their features for Kirby. This package should be used if you want to store your project credentials or variables in a separate place from your code or if you want to have development and production access in different places.

Installation

Installation with composer

composer require beebmx/kirby-env

Usage

You don't need to do anything if your want to access in any $page, just use the page method:

$page->env('VAR');

But if you want to set variables in your config.php file, first you need to load the object with:

\Beebmx\KirbyEnv::load('main/path');

You need to have an .env file in your main/path directory.
You can store any credentials or variables secure like:

KIRBY_DEBUG=false

SECRET_KEY=my_secret_key
PUBLIC_KEY=my_public_key

FOO=BAR
BAZ=${FOO}

Options

When you create an instance of \Beebmx\KirbyEnv you need to load the environment with:

\Beebmx\KirbyEnv::load();

If you require the immutability provides by vlucas/phpdotenv, just:

\Beebmx\KirbyEnv::overload();

Example

Here's an example of a configuration in config.phpfile:

<?php

\Beebmx\KirbyEnv::load('main/path');

return [
    'debug' => env('KIRBY_DEBUG', false),
    'SECRET' => env('SECRET_KEY'),
    'PUBLIC' => env('PUBLIC_KEY'),
];

Usage note

It is important that you add to your .gitignore the .env file. The main/path is where the .env file is located.

kirby-env's People

Contributors

beebmx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

kirby-env's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.