Skip to content

Commit 4d0f5d8

Browse files
committed
✨ added site methods
📝 improved readme Signed-off-by: Bruno Meilick <[email protected]>
1 parent 6c9fbd6 commit 4d0f5d8

File tree

5 files changed

+26
-11
lines changed

5 files changed

+26
-11
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ KIRBY_API_PW=37e30ad867ff3a427317dcd1852abbd692b39ffc
5050

5151
## Usage everywhere but in Config files
5252

53-
> ATTENTION: The PHP functions `getenv` or `putenv` are not supported by this plugin since v2. Do use super globals `$_ENV`, `$_SERVER` or the plugins helper `env()`.
53+
> ⚠️ ATTENTION: The global PHP functions `getenv()` or `putenv()` are NOT supported by this plugin since v2. What will work...
54+
> - use super globals `$_ENV[]`, `$_SERVER[]` or
55+
> - the plugins global helper function `env()` or
56+
> - `->getenv()`, `->env()` page and site methods
5457
5558
**on server**
5659
```php
@@ -59,6 +62,8 @@ echo env('APP_DEBUG'); // false
5962
// or
6063
echo $page->getenv('ALGOLIA_APIKEY'); // 12d7331a21d8a28b3069c49830f463e833e30f6d
6164
echo $page->env('ALGOLIA_APIKEY'); // 12d7331a21d8a28b3069c49830f463e833e30f6d
65+
echo site()->getenv('ALGOLIA_APIKEY'); // 12d7331a21d8a28b3069c49830f463e833e30f6d
66+
echo site()->env('ALGOLIA_APIKEY'); // 12d7331a21d8a28b3069c49830f463e833e30f6d
6267
```
6368

6469
**on staging server**
@@ -68,6 +73,8 @@ echo env('APP_DEBUG'); // true
6873
// or
6974
echo $page->getenv('ALGOLIA_APIKEY'); // 37e30ad867ff3a427317dcd1852abbd692b39ffc
7075
echo $page->env('ALGOLIA_APIKEY'); // 37e30ad867ff3a427317dcd1852abbd692b39ffc
76+
echo site()->getenv('ALGOLIA_APIKEY'); // 37e30ad867ff3a427317dcd1852abbd692b39ffc
77+
echo site()->env('ALGOLIA_APIKEY'); // 37e30ad867ff3a427317dcd1852abbd692b39ffc
7178
```
7279

7380
## Usage in Config files
@@ -78,7 +85,7 @@ See [config examples](https://github.com/bnomei/kirby3-dotenv/tree/master/tests/
7885

7986
| bnomei.dotenv. | Default | Description |
8087
|---------------------------|----------------|---------------------------|
81-
| dir | `callback` | returning `kirby()->roots()->index(). When installing Kirby 3 with Composer use a `function() { return realpath(kirby()->roots()->index() . '/../'); }` |
88+
| dir | `callback` | returning `kirby()->roots()->index().` When installing Kirby 3 with Composer use a `function() { return realpath(kirby()->roots()->index() . '/../'); }` |
8289
| file | `.env` | |
8390
| required | `[]` | You can define required variables in the Settings using an array. If any of these is missing a `RuntimeException` will be thrown. |
8491
| setup | `callback` | perform additional tasks on raw dotenv class instance |

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.3",
4+
"version": "2.0.4",
55
"description": "Kirby 3 Plugin for environment variables from .env",
66
"license": "MIT",
77
"authors": [

index.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,12 @@
2424
return \Bnomei\DotEnv::getenv($env);
2525
},
2626
],
27+
'siteMethods' => [
28+
'env' => function (string $env) {
29+
return \Bnomei\DotEnv::getenv($env);
30+
},
31+
'getenv' => function (string $env) {
32+
return \Bnomei\DotEnv::getenv($env);
33+
},
34+
],
2735
]);

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.3',
31-
'version' => '2.0.3.0',
30+
'pretty_version' => '2.0.4',
31+
'version' => '2.0.4.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.3',
43-
'version' => '2.0.3.0',
42+
'pretty_version' => '2.0.4',
43+
'version' => '2.0.4.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.3',
5-
'version' => '2.0.3.0',
4+
'pretty_version' => '2.0.4',
5+
'version' => '2.0.4.0',
66
'aliases' =>
77
array (
88
),
@@ -13,8 +13,8 @@
1313
array (
1414
'bnomei/kirby3-dotenv' =>
1515
array (
16-
'pretty_version' => '2.0.3',
17-
'version' => '2.0.3.0',
16+
'pretty_version' => '2.0.4',
17+
'version' => '2.0.4.0',
1818
'aliases' =>
1919
array (
2020
),

0 commit comments

Comments
 (0)