PHPackages                             jevets/kirby-phpdotenv - 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. jevets/kirby-phpdotenv

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

jevets/kirby-phpdotenv
======================

PHPDotenv for Kirby CMS

0.0.3(10y ago)510.3k↓23.1%BSDPHPPHP &gt;=5.3.0

Since Mar 30Pushed 8y ago1 watchersCompare

[ Source](https://github.com/jevets/kirby-phpdotenv)[ Packagist](https://packagist.org/packages/jevets/kirby-phpdotenv)[ Docs](https://github.com/jevets/kirby-phpdotenv)[ RSS](/packages/jevets-kirby-phpdotenv/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

kirby-phpdotenv
===============

[](#kirby-phpdotenv)

A simple wrapper around [vlucas' PHP dotenv library](https://github.com/vlucas/phpdotenv) for [Kirby CMS](http://getkirby.com).

Why?
----

[](#why)

I've been using `.env` in my Kirby projects for a while, but I got tired of pasting in the `env()` function for every new site. So, I created this package instead.

Quick Example
-------------

[](#quick-example)

```
# .env
APP_DEBUG=true
```

```
# site/config/config.php
c::set('debug', env('APP_DEBUG', false));
```

```
# elsewhere
c::get('debug'); // true
```

Install
-------

[](#install)

Install via composer

```
composer require jevets/kirby-phpdotenv
```

Usage
-----

[](#usage)

### 1. Instantiate

[](#1-instantiate)

In your site's `index.php` file (or in [`site.php` file](http://getkirby.com/docs/advanced/customized-folder-setup)), load Composer's autoloader.

```
require_once 'path/to/vendor/autoload.php';
```

Then instantiate with:

1. The path where dotenv can find your `.env` file
2. A file name other than `.env`

```
new Jevets\Kirby\Dotenv\Dotenv(__DIR__ . DS, '.env');
```

**Note:** `Jevets\Kirby\Dotenv\Dotenv` will instantiate *and* run `[dotenv]->load()` for you.

### 2. Create your `.env` file

[](#2-create-your-env-file)

```
KIRBY_LICENSE=1234-12345-123456

APP_MODE=production
APP_DEBUG=true
```

### 3. Use in `config.php` file(s)

[](#3-use-in-configphp-files)

```
c::set('license', env('KIRBY_LICENSE', 'put your license in .env'));
c::set('debug', env('APP_DEBUG', false));

c::get('license'); // "1234-12345-123456"
c::get('debug'); // true
```

This library loads a global helper function:

`function env($key, $default = '') {...}`

**Note** `function env()` declaration is wrapped in `if (!function_exists('env'))` so you can override it or use your own method.

Customized folder setup
-----------------------

[](#customized-folder-setup)

In my Kirby projects, I usually keep this folder structure:

```
project/
  .env
  .env.example
  .gitignore
  package.json
  composer.json
  site/
    accounts/
    blueprints/
    cache/
    config/
    snippets/
    templates/
  public/
    kirby/
      toolkit/
    panel/
    content/
    assets/
    thumbs/
    index.php
    site.php
  src/
  vendor/
```

And here's my typical `site.php`

```
# Composer autoload
require __DIR__ . DS . '..' . DS . 'vendor' . DS . 'autoload.php';

# DotEnv
new Jevets\Kirby\Dotenv\Dotenv(__DIR__ . DS . '..');

# Setup Kirby
$kirby = kirby();
$kirby->roots()->site = __DIR__ . DS . '..' . DS . 'site';
```

ChangeLog
---------

[](#changelog)

### 0.0.3

[](#003)

- Rename class alias in helpers.php from `String` to `Str` for PHP7 compatibility

### 0.0.2

[](#002)

- Initial release

Collaborating
-------------

[](#collaborating)

Pull requests and suggestions are quite welcome!

Credits
-------

[](#credits)

- All credit for dotenv goes to vlucas for his great work on [PHP dotenv](https://github.com/vlucas/phpdotenv). I just wrapped it up in a package to speed up development of Kirby-based sites.
- I stole Taylor Otwell's `env()` function from [Laravel 5.1](http://laravel.com/), with a couple tweaks to get it working with Kirby.

Bugs/Issues
-----------

[](#bugsissues)

Please use the issue tracker on the [GitHub repo](https://github.com/jevets/kirby-phpdotenv/issues).

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3701d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dadf2ced41156bc7bb10007dcfaf18fb6cea2ca679439254567771ac001ca2e2?d=identicon)[jevets](/maintainers/jevets)

---

Top Contributors

[![jevets](https://avatars.githubusercontent.com/u/1187075?v=4)](https://github.com/jevets "jevets (22 commits)")[![barnabas-szekeres](https://avatars.githubusercontent.com/u/1658432?v=4)](https://github.com/barnabas-szekeres "barnabas-szekeres (1 commits)")

---

Tags

environmentdotenvkirby

### Embed Badge

![Health badge](/badges/jevets-kirby-phpdotenv/health.svg)

```
[![Health](https://phpackages.com/badges/jevets-kirby-phpdotenv/health.svg)](https://phpackages.com/packages/jevets-kirby-phpdotenv)
```

###  Alternatives

[vlucas/phpdotenv

Loads environment variables from `.env` to `getenv()`, `$\_ENV` and `$\_SERVER` automagically.

13.5k602.4M5.4k](/packages/vlucas-phpdotenv)[symfony/dotenv

Registers environment variables from a .env file

3.8k226.7M2.3k](/packages/symfony-dotenv)[bnomei/kirby3-dotenv

Kirby Plugin for environment variables from .env

4144.1k1](/packages/bnomei-kirby3-dotenv)[beebmx/kirby-env

Enable env variables to Kirby

2037.9k2](/packages/beebmx-kirby-env)[nystudio107/dotenvy

Speed up your production sites by ditching .env for key/value variable pairs as Apache, Nginx, and shell equivalents.

326.9k](/packages/nystudio107-dotenvy)[johannschopplich/kirby-helpers

Environment, SEO, and build utilities for Kirby CMS

277.4k](/packages/johannschopplich-kirby-helpers)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
