1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Cryptommer\Smsir; |
4
|
|
|
|
5
|
|
|
use Cryptommer\Smsir\Classes\Smsir; |
|
|
|
|
6
|
|
|
use Illuminate\Support\ServiceProvider; |
7
|
|
|
|
8
|
|
|
class SmsirServiceProvider extends ServiceProvider |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Bootstrap the application services. |
12
|
|
|
*/ |
13
|
|
|
public function boot() |
14
|
|
|
{ |
15
|
|
|
/* |
16
|
|
|
* Optional methods to load your package assets |
17
|
|
|
*/ |
18
|
|
|
$this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'Smsir'); |
19
|
|
|
// $this->loadViewsFrom(__DIR__.'/../resources/views', 'Smsir'); |
20
|
|
|
// $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
21
|
|
|
// $this->loadRoutesFrom(__DIR__.'/routes.php'); |
22
|
|
|
|
23
|
|
|
if ($this->app->runningInConsole()) { |
24
|
|
|
$this->publishes([ |
25
|
|
|
__DIR__.'/../config/config.php' => config_path('smsir.php'), |
26
|
|
|
], 'config'); |
27
|
|
|
|
28
|
|
|
// Publishing the views. |
29
|
|
|
/*$this->publishes([ |
30
|
|
|
__DIR__.'/../resources/views' => resource_path('views/vendor/Smsir'), |
31
|
|
|
], 'views');*/ |
32
|
|
|
|
33
|
|
|
// Publishing assets. |
34
|
|
|
/*$this->publishes([ |
35
|
|
|
__DIR__.'/../resources/assets' => public_path('vendor/Smsir'), |
36
|
|
|
], 'assets');*/ |
37
|
|
|
|
38
|
|
|
// Publishing the translation files. |
39
|
|
|
$this->publishes([ |
40
|
|
|
__DIR__.'/../resources/lang' => resource_path('lang/vendor/Smsir'), |
41
|
|
|
], 'lang'); |
42
|
|
|
|
43
|
|
|
// Registering package commands. |
44
|
|
|
// $this->commands([]); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Register the application services. |
50
|
|
|
*/ |
51
|
|
|
public function register() |
52
|
|
|
{ |
53
|
|
|
// Automatically apply the package configuration |
54
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'smsir'); |
55
|
|
|
|
56
|
|
|
// Register the main class to use with the facade |
57
|
|
|
$this->app->singleton('Smsir', function () { |
58
|
|
|
return new Smsir(); |
59
|
|
|
}); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
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: