1 | <?php |
||
16 | class LaravelModulesServiceProvider extends ServiceProvider |
||
17 | { |
||
18 | /** |
||
19 | * Indicates if loading of the provider is deferred. |
||
20 | * |
||
21 | * @var bool |
||
22 | */ |
||
23 | protected $defer = false; |
||
24 | |||
25 | /** |
||
26 | * Booting the package. |
||
27 | */ |
||
28 | 55 | public function boot() |
|
34 | |||
35 | /** |
||
36 | * Register all modules. |
||
37 | */ |
||
38 | 55 | protected function registerModules() |
|
42 | |||
43 | /** |
||
44 | * Register the service provider. |
||
45 | */ |
||
46 | 55 | public function register() |
|
52 | |||
53 | /** |
||
54 | * Setup stub path. |
||
55 | */ |
||
56 | 55 | public function setupStubPath() |
|
66 | |||
67 | /** |
||
68 | * Register package's namespaces. |
||
69 | */ |
||
70 | 55 | protected function registerNamespaces() |
|
78 | |||
79 | /** |
||
80 | * Register laravel html package. |
||
81 | */ |
||
82 | protected function registerHtml() |
||
94 | |||
95 | /** |
||
96 | * Register the service provider. |
||
97 | */ |
||
98 | protected function registerServices() |
||
106 | |||
107 | /** |
||
108 | * Get the services provided by the provider. |
||
109 | * |
||
110 | * @return array |
||
111 | */ |
||
112 | public function provides() |
||
116 | |||
117 | /** |
||
118 | * Register providers. |
||
119 | */ |
||
120 | 55 | protected function registerProviders() |
|
125 | } |
||
126 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: