Skip to content

Commit b185dc5

Browse files
committed
🐛 fixed non composer setups
Signed-off-by: Bruno Meilick <[email protected]>
1 parent ecc79e2 commit b185dc5

File tree

8 files changed

+40
-26
lines changed

8 files changed

+40
-26
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ This plugin is free but if you use it in a commercial project please consider to
1616
- [buy me ☕](https://buymeacoff.ee/bnomei) or
1717
- [buy a Kirby license using this affiliate link](https://a.paddle.com/v2/click/1129/35731?link=1170)
1818

19+
## Similar Plugins
20+
21+
- [beebmx/kirby-env](https://github.com/beebmx/kirby-env)
22+
- [johannschopplich/kirby-extended](https://github.com/johannschopplich/kirby-extended)
23+
1924
## Installation
2025

2126
- unzip [master.zip](https://github.com/bnomei/kirby3-dotenv/archive/master.zip) as folder `site/plugins/kirby3-dotenv` or
@@ -53,6 +58,7 @@ echo $_ENV['APP_MODE']; // production
5358
echo env('APP_DEBUG'); // false
5459
// or
5560
echo $page->getenv('ALGOLIA_APIKEY'); // 12d7331a21d8a28b3069c49830f463e833e30f6d
61+
echo $page->env('ALGOLIA_APIKEY'); // 12d7331a21d8a28b3069c49830f463e833e30f6d
5662
```
5763

5864
**on staging server**
@@ -61,6 +67,7 @@ echo $_ENV['APP_MODE']; // staging
6167
echo env('APP_DEBUG'); // true
6268
// or
6369
echo $page->getenv('ALGOLIA_APIKEY'); // 37e30ad867ff3a427317dcd1852abbd692b39ffc
70+
echo $page->env('ALGOLIA_APIKEY'); // 37e30ad867ff3a427317dcd1852abbd692b39ffc
6471
```
6572

6673
## Usage in Config files

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "bnomei/kirby3-dotenv",
33
"type": "kirby-plugin",
4-
"version": "2.0.0",
4+
"version": "2.0.1",
55
"description": "Kirby 3 Plugin for environment variables from .env",
66
"license": "MIT",
77
"authors": [

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

global.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
require_once __DIR__ . '/classes/DotEnv.php';
4+
5+
if (! function_exists('loadenv')) {
6+
function loadenv(array $options = [])
7+
{
8+
return \Bnomei\DotEnv::load($options);
9+
}
10+
}
11+
12+
if (! function_exists('env')) {
13+
function env(string $env)
14+
{
15+
return \Bnomei\DotEnv::getenv($env);
16+
}
17+
}

index.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
@include_once __DIR__ . '/vendor/autoload.php';
4+
@include_once __DIR__ . '/global.php';
45

56
Kirby::plugin('bnomei/dotenv', [
67
'options' => [
@@ -16,22 +17,11 @@
1617
}
1718
],
1819
'pageMethods' => [
20+
'env' => function (string $env) {
21+
return \Bnomei\DotEnv::getenv($env);
22+
},
1923
'getenv' => function (string $env) {
2024
return \Bnomei\DotEnv::getenv($env);
2125
},
2226
],
2327
]);
24-
25-
if (! function_exists('loadenv')) {
26-
function loadenv(array $options = [])
27-
{
28-
return \Bnomei\DotEnv::load($options);
29-
}
30-
}
31-
32-
if (! function_exists('env')) {
33-
function env(string $env)
34-
{
35-
return \Bnomei\DotEnv::getenv($env);
36-
}
37-
}

tests/site/config/config.staging.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

33
// load dotenv plugins class so getenv can be used outside of closures
4-
require_once __DIR__ . '/../../../classes/DotEnv.php';
5-
// require_once __DIR__ . '/../plugins/kirby3-dotenv/classes/DotEnv.php';
4+
require_once __DIR__ . '/../../../global.php';
5+
// require_once __DIR__ . '/../plugins/kirby3-dotenv/global.php';
66

77
loadenv([
88
'dir' => realpath(__DIR__ . '/../../'),

vendor/composer/InstalledVersions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class InstalledVersions
2727
private static $installed = array (
2828
'root' =>
2929
array (
30-
'pretty_version' => '2.0.0',
31-
'version' => '2.0.0.0',
30+
'pretty_version' => '2.0.1',
31+
'version' => '2.0.1.0',
3232
'aliases' =>
3333
array (
3434
),
@@ -39,8 +39,8 @@ class InstalledVersions
3939
array (
4040
'bnomei/kirby3-dotenv' =>
4141
array (
42-
'pretty_version' => '2.0.0',
43-
'version' => '2.0.0.0',
42+
'pretty_version' => '2.0.1',
43+
'version' => '2.0.1.0',
4444
'aliases' =>
4545
array (
4646
),

vendor/composer/installed.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php return array (
22
'root' =>
33
array (
4-
'pretty_version' => '2.0.0',
5-
'version' => '2.0.0.0',
4+
'pretty_version' => '2.0.1',
5+
'version' => '2.0.1.0',
66
'aliases' =>
77
array (
88
),
@@ -13,8 +13,8 @@
1313
array (
1414
'bnomei/kirby3-dotenv' =>
1515
array (
16-
'pretty_version' => '2.0.0',
17-
'version' => '2.0.0.0',
16+
'pretty_version' => '2.0.1',
17+
'version' => '2.0.1.0',
1818
'aliases' =>
1919
array (
2020
),

0 commit comments

Comments
 (0)