File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Bnomei ;
4+
5+ class DotEnv
6+ {
7+ private static $ envLoaded = false ;
8+ public static function load ()
9+ {
10+ if (!static ::$ envLoaded ) {
11+ $ dir = option ('bnomei.dotenv.dir ' , kirby ()->roots ()->index ());
12+ if ($ dir && is_callable ($ dir )) {
13+ $ dir = $ dir ();
14+ }
15+ $ dotenv = new \Dotenv \Dotenv ($ dir );
16+ $ dotenv ->load ();
17+ $ require = \option ('bnomei.dotenv.required ' );
18+ if ($ require && is_array ($ require ) && count ($ require ) > 0 ) {
19+ $ dotenv ->required ($ require );
20+ // TODO: type check
21+ }
22+ }
23+ }
24+
25+ public static function getenv (string $ env )
26+ {
27+ static ::load ();
28+ return \getenv ($ env );
29+ }
30+ }
Original file line number Diff line number Diff line change 11{
22 "name" : " bnomei/kirby3-dotenv" ,
33 "type" : " plugin" ,
4- "version" : " 1.0.3 " ,
4+ "version" : " 1.0.4 " ,
55 "description" : " Kirby 3 Plugin for environment variables from .env" ,
66 "license" : " MIT" ,
77 "authors" : [
You can’t perform that action at this time.
0 commit comments