File tree Expand file tree Collapse file tree 3 files changed +58
-3
lines changed Expand file tree Collapse file tree 3 files changed +58
-3
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ Laravel Env Validator is available via Composer:
25
25
}
26
26
```
27
27
28
+ ## Setup
29
+
30
+ ### Laravel
31
+
32
+ #### Register Service Provider
33
+
28
34
``` php
29
35
// config/app.php
30
36
@@ -35,11 +41,39 @@ Laravel Env Validator is available via Composer:
35
41
],
36
42
```
37
43
44
+ #### Publish configuration file
45
+
38
46
```
39
47
php artisan vendor:publish --provider="MathiasGrimm\LaravelEnvValidator\ServiceProvider" --tag="config"
40
48
```
41
49
42
- ## Example
50
+ ### Lumen
51
+
52
+ Manually copy the configuration file
53
+ ```
54
+ vendor/mathiasgrimm/laravel-env-validator/src/config/laravel-env-validator.php
55
+ ```
56
+
57
+ to
58
+
59
+ ```
60
+ config/laravel-env-validator.php
61
+ ```
62
+
63
+ Register Service Provider in ` bootstrap/app.php ` :
64
+
65
+ ``` php
66
+ ...
67
+ $app->register(MathiasGrimm\LaravelEnvValidator\LumenServiceProvider::class);
68
+ ...
69
+ ```
70
+
71
+ Load configuration file in ` bootstrap/app.php ` :
72
+ ``` php
73
+ $app->configure('laravel-env-validator');
74
+ ```
75
+
76
+ ## Example configuration file
43
77
``` php
44
78
<?php
45
79
// config/laravel-env-validator.php
Original file line number Diff line number Diff line change @@ -15,8 +15,7 @@ public static function buildFromValidator(Validator $validator)
15
15
16
16
public static function buildFromLaravelConfig ()
17
17
{
18
- $ config = \Config::get ('laravel-env-validator ' );
19
-
18
+ $ config = config ('laravel-env-validator ' );
20
19
// there is a bug that would not load APP_ENV into $_SERVER or $_ENV
21
20
// therefore I had to read based on what was defined in the config file
22
21
$ env = [];
Original file line number Diff line number Diff line change
1
+ <?php namespace MathiasGrimm \LaravelEnvValidator ;
2
+
3
+ use Illuminate \Support \ServiceProvider as Provider ;
4
+
5
+ class LumenServiceProvider extends Provider
6
+ {
7
+ public function boot ()
8
+ {
9
+ $ validator = EnvValidatorFactory::buildFromLaravelConfig ();
10
+ $ validator ->validate ();
11
+ }
12
+
13
+ /**
14
+ * Register any application services.
15
+ *
16
+ * @return void
17
+ */
18
+ public function register ()
19
+ {
20
+ $ this ->mergeConfigFrom (__DIR__ . '/config/laravel-env-validator.php ' , 'laravel-env-validator ' );
21
+ }
22
+ }
You can’t perform that action at this time.
0 commit comments