1 | <?php |
||
12 | abstract class AppServiceProvider extends AbstractServiceProvider implements BootableServiceProviderInterface |
||
13 | { |
||
14 | protected $provides = [ |
||
15 | Config::class, |
||
16 | 'environment', |
||
17 | 'base_path', |
||
18 | 'resources_path', |
||
19 | ]; |
||
20 | |||
21 | /** |
||
22 | * Determine environment where application is currently is running on. |
||
23 | * |
||
24 | * @return string |
||
25 | */ |
||
26 | abstract public function environment(): string; |
||
27 | |||
28 | /** |
||
29 | * Base path of the application. |
||
30 | * |
||
31 | * @return string |
||
32 | */ |
||
33 | abstract public function basePath(): string; |
||
34 | |||
35 | /** |
||
36 | * Path to the "resources folder". |
||
37 | * |
||
38 | * @return string |
||
39 | */ |
||
40 | abstract public function resourcesPath(): string; |
||
41 | |||
42 | /** |
||
43 | * Method will be invoked on registration of a service provider implementing |
||
44 | * this interface. Provides ability for eager loading of Service Providers. |
||
45 | * |
||
46 | * @return void |
||
47 | */ |
||
48 | 2 | public function boot(): void |
|
49 | { |
||
50 | try { |
||
51 | 2 | (new Dotenv($this->basePath()))->load(); |
|
52 | 1 | } catch (InvalidPathException $exception) { |
|
|
|||
53 | } |
||
54 | |||
55 | 2 | $this->container->share(Config::class, function () { |
|
56 | 2 | return new Config($_ENV); |
|
57 | 2 | }); |
|
58 | 2 | } |
|
59 | |||
60 | /** |
||
61 | * Use the register method to register items with the container via the |
||
62 | * protected $this->container property or the `getContainer` method |
||
63 | * from the ContainerAwareTrait. |
||
64 | * |
||
65 | * @return void |
||
66 | */ |
||
67 | 2 | public function register(): void |
|
73 | } |
||
74 |