Download the PHP package jevets/kirby-phpdotenv without Composer
On this page you can find all versions of the php package jevets/kirby-phpdotenv. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jevets/kirby-phpdotenv
More information about jevets/kirby-phpdotenv
Files in jevets/kirby-phpdotenv
Package kirby-phpdotenv
Short Description PHPDotenv for Kirby CMS
License BSD
Homepage https://github.com/jevets/kirby-phpdotenv
Informations about the package kirby-phpdotenv
kirby-phpdotenv
A simple wrapper around vlucas' PHP dotenv library for Kirby CMS.
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
Install
Install via composer
Usage
1. Instantiate
In your site's index.php
file (or in site.php
file), load Composer's autoloader.
Then instantiate with:
- The path where dotenv can find your
.env
file - A file name other than
.env
Note: Jevets\Kirby\Dotenv\Dotenv
will instantiate and run [dotenv]->load()
for you.
2. Create your .env
file
3. Use in config.php
file(s)
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
In my Kirby projects, I usually keep this folder structure:
And here's my typical site.php
ChangeLog
0.0.3
- Rename class alias in helpers.php from
String
toStr
for PHP7 compatibility
0.0.2
- Initial release
Collaborating
Pull requests and suggestions are quite welcome!
Credits
- All credit for dotenv goes to vlucas for his great work on PHP dotenv. 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, with a couple tweaks to get it working with Kirby.
Bugs/Issues
Please use the issue tracker on the GitHub repo.