1
|
|
|
<?php
|
2
|
|
|
|
3
|
|
|
namespace Resta\Foundation\Bootstrapper;
|
4
|
|
|
|
5
|
|
|
use Resta\Router\Route;
|
6
|
|
|
use Resta\Support\Utils;
|
7
|
|
|
use Resta\Url\UrlProvider;
|
8
|
|
|
use Resta\Router\RouteProvider;
|
9
|
|
|
use Resta\Logger\LoggerProvider;
|
10
|
|
|
use Resta\Config\ConfigProvider;
|
11
|
|
|
use Resta\Console\ConsoleProvider;
|
12
|
|
|
use Resta\Contracts\BootContracts;
|
13
|
|
|
use Resta\Provider\ServiceProvider;
|
14
|
|
|
use Resta\Response\ResponseProvider;
|
15
|
|
|
use Resta\Middleware\MiddlewareProvider;
|
16
|
|
|
use Resta\Foundation\ApplicationProvider;
|
17
|
|
|
use Resta\Environment\EnvironmentProvider;
|
18
|
|
|
use Resta\Encrypter\EncrypterProvider as EncrypterProvider;
|
|
|
|
|
19
|
|
|
|
20
|
|
|
class BootLoader extends ApplicationProvider implements BootContracts
|
21
|
|
|
{
|
22
|
|
|
/**
|
23
|
|
|
* @var string
|
24
|
|
|
*/
|
25
|
|
|
private $bootstrapper;
|
26
|
|
|
|
27
|
|
|
/**
|
28
|
|
|
* app console method
|
29
|
|
|
*
|
30
|
|
|
* @return mixed|void
|
31
|
|
|
*/
|
32
|
|
|
private function console()
|
33
|
|
|
{
|
34
|
|
|
//if the console is true
|
35
|
|
|
//console app runner
|
36
|
|
|
if($this->app->runningInConsole()
|
37
|
|
|
&& $this->app['isAvailableStore'] && $this->app->checkBindings('appConsole')===false){
|
38
|
|
|
|
39
|
|
|
//If the second parameter is sent true to the application builder,
|
40
|
|
|
//all operations are performed by the console and the custom booting are executed
|
41
|
|
|
$this->app->share('appConsole',ConsoleProvider::class);
|
42
|
|
|
}
|
43
|
|
|
}
|
44
|
|
|
|
45
|
|
|
/**
|
46
|
|
|
* default distributor boot method
|
47
|
|
|
*
|
48
|
|
|
* @return void
|
49
|
|
|
*/
|
50
|
|
|
public function boot()
|
51
|
|
|
{
|
52
|
|
|
$this->{$this->bootstrapper}();
|
53
|
|
|
}
|
54
|
|
|
|
55
|
|
|
/**
|
56
|
|
|
* config provider boot
|
57
|
|
|
*
|
58
|
|
|
* @return mixed|void
|
59
|
|
|
*/
|
60
|
|
|
private function config()
|
61
|
|
|
{
|
62
|
|
|
// this is your application's config installer.
|
63
|
|
|
// you can easily access the config variables with the config installer.
|
64
|
|
|
if($this->app->checkBindings('config')===false){
|
65
|
|
|
$this->app->share('config',function($app){
|
66
|
|
|
return $app['revision']['config'] ?? ConfigProvider::class;
|
67
|
|
|
});
|
68
|
|
|
}
|
69
|
|
|
}
|
70
|
|
|
|
71
|
|
|
/**
|
72
|
|
|
* environment boot
|
73
|
|
|
*
|
74
|
|
|
* @return mixed|void
|
75
|
|
|
*/
|
76
|
|
|
private function environment()
|
77
|
|
|
{
|
78
|
|
|
// it is often helpful to have different configuration values based onUrlParseApplication
|
79
|
|
|
// the environment where the application is running.for example,
|
80
|
|
|
// you may wish to use a different cache driver locally than you do on your production server.
|
81
|
|
|
if($this->app->checkBindings('environment')===false){
|
82
|
|
|
$this->app->share('environment',function($app){
|
83
|
|
|
return $app['revision']['environment'] ?? EnvironmentProvider::class;
|
84
|
|
|
});
|
85
|
|
|
}
|
86
|
|
|
}
|
87
|
|
|
|
88
|
|
|
/**
|
89
|
|
|
* event dispatcher boot
|
90
|
|
|
*
|
91
|
|
|
* @return mixed|void
|
92
|
|
|
*/
|
93
|
|
|
private function eventDispatcher()
|
94
|
|
|
{
|
95
|
|
|
// the eventDispatcher component provides tools
|
96
|
|
|
// that allow your application components to communicate
|
97
|
|
|
// with each other by dispatching events and listening to them.
|
98
|
|
|
if($this->app->checkBindings('eventDispatcher')===false){
|
99
|
|
|
$this->app->share('eventDispatcher',function($app){
|
100
|
|
|
if(Utils::isNamespaceExists(app()->namespace()->serviceEventDispatcher())){
|
101
|
|
|
return $app['revision']['eventDispatcher'] ?? app()->namespace()->serviceEventDispatcher();
|
102
|
|
|
}
|
103
|
|
|
});
|
104
|
|
|
}
|
105
|
|
|
|
106
|
|
|
}
|
107
|
|
|
|
108
|
|
|
/**
|
109
|
|
|
* logger boot
|
110
|
|
|
*
|
111
|
|
|
* @return mixed|void
|
112
|
|
|
*/
|
113
|
|
|
private function logger()
|
114
|
|
|
{
|
115
|
|
|
// to help you learn more about what's happening within your application,
|
116
|
|
|
// rest system provides robust logging services that allow you to log messages to files,
|
117
|
|
|
// the system error log, and even to Slack to notify your entire team.
|
118
|
|
|
if($this->app->checkBindings('logger')===false){
|
119
|
|
|
$this->app->share('logger',function($app){
|
120
|
|
|
return $app['revision']['logger'] ?? LoggerProvider::class;
|
121
|
|
|
});
|
122
|
|
|
}
|
123
|
|
|
|
124
|
|
|
}
|
125
|
|
|
|
126
|
|
|
/**
|
127
|
|
|
* middleware boot
|
128
|
|
|
*
|
129
|
|
|
* @return mixed|void
|
130
|
|
|
*/
|
131
|
|
|
private function middleware()
|
132
|
|
|
{
|
133
|
|
|
// when your application is requested, the middleware classes are running before all bootstrapper executables.
|
134
|
|
|
// thus, if you make http request your application, you can verify with an intermediate middleware layer
|
135
|
|
|
// and throw an exception.
|
136
|
|
|
if($this->app->checkBindings('middleware')===false){
|
137
|
|
|
$this->app->make('middleware',function($app){
|
138
|
|
|
return $app['revision']['middleware'] ?? MiddlewareProvider::class;
|
139
|
|
|
});
|
140
|
|
|
}
|
141
|
|
|
}
|
142
|
|
|
|
143
|
|
|
/**
|
144
|
|
|
* response manager boot
|
145
|
|
|
*
|
146
|
|
|
* @return mixed|void
|
147
|
|
|
*/
|
148
|
|
|
private function response()
|
149
|
|
|
{
|
150
|
|
|
// we determine kind of output with the response manager
|
151
|
|
|
// json as default or [xml,wsdl]
|
152
|
|
|
if($this->app->checkBindings('response')===false){
|
153
|
|
|
$this->app->make('response',function($app){
|
154
|
|
|
return $app['revision']['response'] ?? ResponseProvider::class;
|
155
|
|
|
});
|
156
|
|
|
}
|
157
|
|
|
}
|
158
|
|
|
|
159
|
|
|
/**
|
160
|
|
|
* router boot
|
161
|
|
|
*
|
162
|
|
|
* @return mixed|void
|
163
|
|
|
*/
|
164
|
|
|
private function route()
|
165
|
|
|
{
|
166
|
|
|
// route operations are the last part of the system run. In this section,
|
167
|
|
|
// a route operation is passed through the url process and output is sent to the screen according to
|
168
|
|
|
// the method file to be called by the application
|
169
|
|
|
if(core()->isAvailableStore && $this->app->checkBindings('route')===false){
|
170
|
|
|
$this->app->share('route',function($app){
|
171
|
|
|
return $app['revision']['route'] ?? Route::class;
|
172
|
|
|
});
|
173
|
|
|
}
|
174
|
|
|
}
|
175
|
|
|
|
176
|
|
|
/**
|
177
|
|
|
* router boot
|
178
|
|
|
*
|
179
|
|
|
* @return mixed|void
|
180
|
|
|
*/
|
181
|
|
|
private function router()
|
182
|
|
|
{
|
183
|
|
|
// route operations are the last part of the system run. In this section,
|
184
|
|
|
// a route operation is passed through the url process and output is sent to the screen according to
|
185
|
|
|
// the method file to be called by the application
|
186
|
|
|
if(core()->isAvailableStore && $this->app->checkBindings('router')===false){
|
187
|
|
|
$this->app->make('router',function($app){
|
188
|
|
|
return $app['revision']['router'] ?? RouteProvider::class;
|
189
|
|
|
});
|
190
|
|
|
}
|
191
|
|
|
}
|
192
|
|
|
|
193
|
|
|
/**
|
194
|
|
|
* service provider boot
|
195
|
|
|
*
|
196
|
|
|
* @return mixed|void
|
197
|
|
|
*/
|
198
|
|
|
private function serviceProvider()
|
199
|
|
|
{
|
200
|
|
|
if($this->app->checkBindings('serviceProvider')===false){
|
201
|
|
|
$this->app->share('serviceProvider',function($app){
|
202
|
|
|
return $app['revision']['serviceProvider'] ?? ServiceProvider::class;
|
203
|
|
|
});
|
204
|
|
|
}
|
205
|
|
|
}
|
206
|
|
|
|
207
|
|
|
/**
|
208
|
|
|
* set bootstrapper property
|
209
|
|
|
*
|
210
|
|
|
* @param string $bootstrapper
|
211
|
|
|
*/
|
212
|
|
|
public function setBootstrapper($bootstrapper)
|
213
|
|
|
{
|
214
|
|
|
$this->bootstrapper = $bootstrapper;
|
215
|
|
|
}
|
216
|
|
|
|
217
|
|
|
/**
|
218
|
|
|
* url provider boot
|
219
|
|
|
*
|
220
|
|
|
* @return mixed|void
|
221
|
|
|
*/
|
222
|
|
|
private function url()
|
223
|
|
|
{
|
224
|
|
|
// with url parsing,the application route for
|
225
|
|
|
// the rest project is determined after the route variables from the URL are assigned to the kernel url object.
|
226
|
|
|
if(count(array_filter(Utils::getRequestPathInfo(),'strlen'))
|
227
|
|
|
&& $this->app->checkBindings('url')===false){
|
228
|
|
|
$this->app->make('url',function($app){
|
229
|
|
|
return $app['revision']['url'] ?? UrlProvider::class;
|
230
|
|
|
});
|
231
|
|
|
}
|
232
|
|
|
}
|
233
|
|
|
|
234
|
|
|
/**
|
235
|
|
|
* special revision boot
|
236
|
|
|
*
|
237
|
|
|
* @param $name
|
238
|
|
|
* @param $arguments
|
239
|
|
|
* @return mixed
|
240
|
|
|
*/
|
241
|
|
|
public function __call($name,$arguments)
|
242
|
|
|
{
|
243
|
|
|
// we use the methodological context
|
244
|
|
|
// for kernel group values that are replaced with revision.
|
245
|
|
|
$revisionBoot = array_search($name,app()->get('revision'));
|
246
|
|
|
if(is_string($revisionBoot) && method_exists($this,$revisionBoot)){
|
247
|
|
|
return $this->{$revisionBoot}();
|
248
|
|
|
}
|
249
|
|
|
|
250
|
|
|
exception()->badFunctionCall('There is no boot method named '.$name);
|
251
|
|
|
}
|
252
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths