1 | <?php |
||
16 | class VatCalculatorServiceProvider 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 | * Bootstrap the application events. |
||
27 | * |
||
28 | * @return void |
||
29 | */ |
||
30 | public function boot() |
||
36 | |||
37 | /** |
||
38 | * Publish Teamwork configuration. |
||
39 | */ |
||
40 | protected function publishConfig() |
||
52 | |||
53 | /** |
||
54 | * Register the service provider. |
||
55 | * |
||
56 | * @return void |
||
57 | */ |
||
58 | public function register() |
||
64 | |||
65 | /** |
||
66 | * Register the application bindings. |
||
67 | * |
||
68 | * @return void |
||
69 | */ |
||
70 | protected function registerVatCalculator() |
||
80 | |||
81 | /** |
||
82 | * Register the vault facade without the user having to add it to the app.php file. |
||
83 | * |
||
84 | * @return void |
||
85 | */ |
||
86 | public function registerFacade() |
||
93 | |||
94 | /** |
||
95 | * Merges user's and teamwork's configs. |
||
96 | * |
||
97 | * @return void |
||
98 | */ |
||
99 | protected function mergeConfig() |
||
105 | |||
106 | protected function registerValidatorExtension() |
||
116 | |||
117 | /** |
||
118 | * Register predefined routes, used for the |
||
119 | * handy javascript toolkit. |
||
120 | */ |
||
121 | protected function registerRoutes() |
||
128 | } |
||
129 |
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: