PHPackages                             beebmx/kirby-env - 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. beebmx/kirby-env

ActiveKirby-plugin[Utility &amp; Helpers](/categories/utility)

beebmx/kirby-env
================

Enable env variables to Kirby

5.1.0(9mo ago)2037.9k↓35.6%1MITPHPPHP ^8.2CI failing

Since Jan 21Pushed 9mo ago2 watchersCompare

[ Source](https://github.com/beebmx/kirby-env)[ Packagist](https://packagist.org/packages/beebmx/kirby-env)[ RSS](/packages/beebmx-kirby-env/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (17)Used By (1)

Env for Kirby
=============

[](#env-for-kirby)

[![Latest Stable Version](https://camo.githubusercontent.com/3e059265e55bc86f2b878b284bfa53ceda89f7bc5cc65df418773a9468c5af21/68747470733a2f2f706f7365722e707567782e6f72672f626565626d782f6b697262792d656e762f76)](//packagist.org/packages/beebmx/kirby-env)[![GitHub Workflow Status](https://camo.githubusercontent.com/d865589281f4bc1f85ab0693b2b3de07f7588e8819a1f94eff42ca7633b6c462/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f626565626d782f6b697262792d656e762f74657374732e796d6c3f6272616e63683d6d61696e)](https://camo.githubusercontent.com/d865589281f4bc1f85ab0693b2b3de07f7588e8819a1f94eff42ca7633b6c462/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f626565626d782f6b697262792d656e762f74657374732e796d6c3f6272616e63683d6d61696e)[![Total Downloads](https://camo.githubusercontent.com/6c042cf235ed5ed1323d6332d9da9e757e69680ef66da033474d191fe83a426a/687474703a2f2f706f7365722e707567782e6f72672f626565626d782f6b697262792d656e762f646f776e6c6f616473)](https://packagist.org/packages/beebmx/kirby-env)[![License](https://camo.githubusercontent.com/d075028caba10694e8ad3dc0417877bf80dedea18764512d155236b1307ed3fc/68747470733a2f2f706f7365722e707567782e6f72672f626565626d782f6b697262792d656e762f6c6963656e7365)](//packagist.org/packages/beebmx/kirby-env)

**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)

### Installation with composer

[](#installation-with-composer)

```
composer require beebmx/kirby-env

```

Usage
-----

[](#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
-------

[](#options)

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

```
\Beebmx\KirbyEnv::load();
```

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

```
\Beebmx\KirbyEnv::overload();
```

Example
-------

[](#example)

Here's an example of a configuration in `config.php`file:

```
