1 | <?php |
||
16 | class TranslationSheetServiceProvider extends ServiceProvider |
||
17 | { |
||
18 | 35 | public function boot() |
|
24 | |||
25 | 35 | public function register() |
|
35 | |||
36 | 35 | private function registerGoogleApiClient() |
|
37 | { |
||
38 | $this->app->singleton(Client::class, function () { |
||
39 | 18 | return Client::create( |
|
40 | 18 | $this->app['config']['translation_sheet.serviceAccountCredentialsFile'], |
|
41 | 18 | $this->app['config']['translation_sheet.googleApplicationName'] |
|
42 | 18 | ); |
|
43 | 35 | }); |
|
44 | 35 | } |
|
45 | |||
46 | 35 | private function registerSpreadsheet() |
|
47 | { |
||
48 | $this->app->singleton(Spreadsheet::class, function () { |
||
49 | 1 | return new Spreadsheet( |
|
50 | 1 | $this->app['config']['translation_sheet.spreadsheetId'], |
|
51 | 1 | $this->asArray($this->app['config']['translation_sheet.locales']) |
|
52 | 1 | ); |
|
53 | 35 | }); |
|
54 | 35 | } |
|
55 | |||
56 | 35 | private function registerCommands() |
|
57 | { |
||
58 | 35 | $this->commands([ |
|
59 | 35 | Setup::class, |
|
60 | 35 | Push::class, |
|
61 | 35 | Pull::class, |
|
62 | 35 | Prepare::class, |
|
63 | 35 | Lock::class, |
|
64 | 35 | Unlock::class, |
|
65 | 35 | Status::class, |
|
66 | 35 | Open::class, |
|
67 | 35 | ]); |
|
68 | 35 | } |
|
69 | |||
70 | 1 | private function asArray($value) |
|
80 | } |
||
81 |
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: