1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App; |
4
|
|
|
|
5
|
|
|
use Illuminate\Container\Container as IlluminateContainer; |
|
|
|
|
6
|
|
|
use Illuminate\Support\Facades\Facade; |
|
|
|
|
7
|
|
|
use Zapheus\Application; |
8
|
|
|
use Zapheus\Bridge\Illuminate\Provider as IlluminateProvider; |
|
|
|
|
9
|
|
|
use Zapheus\Container\CompositeContainer; |
10
|
|
|
use Zapheus\Container\Container as WritableContainer; |
11
|
|
|
use Zapheus\Container\ReflectionContainer; |
12
|
|
|
use Zapheus\Provider\Configuration; |
13
|
|
|
use Zapheus\Provider\FrameworkProvider; |
14
|
|
|
|
15
|
|
|
use App\Application\Controllers\GreetController; |
|
|
|
|
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Bootstrap Container |
19
|
|
|
* |
20
|
|
|
* @package Zapheus |
21
|
|
|
* @author Rougin Royce Gutib <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
class Bootstrap extends CompositeContainer |
24
|
|
|
{ |
25
|
|
|
const ILLUMINATE_CONTAINER = 'Illuminate\Container\Container'; |
26
|
|
|
|
27
|
|
|
const ILLUMINATE_PROVIDER = 'Zapheus\Bridge\Illuminate\Provider'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Static instance of the application container. |
31
|
|
|
* |
32
|
|
|
* @var \Zapheus\Container\ContainerInterface |
33
|
|
|
*/ |
34
|
|
|
protected static $container; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Path of the configurations directory. |
38
|
|
|
* |
39
|
|
|
* @var string |
40
|
|
|
*/ |
41
|
|
|
protected $config = 'app/config'; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Full path of the root directory. |
45
|
|
|
* |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
protected $root; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* An instance of a Container\WritableInterface. |
52
|
|
|
* |
53
|
|
|
* @var \Zapheus\Container\WritableInterface |
54
|
|
|
*/ |
55
|
|
|
protected $writable; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Initializes the container instance. |
59
|
|
|
* |
60
|
|
|
* @param string $root |
61
|
|
|
*/ |
62
|
6 |
|
public function __construct($root) |
63
|
|
|
{ |
64
|
6 |
|
$this->writable = new WritableContainer; |
65
|
|
|
|
66
|
6 |
|
$this->configuration($this->root = $root); |
|
|
|
|
67
|
|
|
|
68
|
|
|
// NOTE: If you want to autowire your classes, you may want |
69
|
|
|
// to use the ReflectionContainer class but it might have an |
70
|
|
|
// effect regarding the performance of the application. Just |
71
|
|
|
// uncomment lines 70 in order to use the mentioned instance. |
72
|
|
|
|
73
|
6 |
|
$this->add(new ReflectionContainer); |
74
|
|
|
|
75
|
|
|
// Define your dependencies below using $this->writable->set() method. |
76
|
|
|
// Documentation: $this->writable->set(string $id, mixed $concrete) |
|
|
|
|
77
|
|
|
|
78
|
|
|
// NOTE: If you enabled the ReflectionContainer above, you can |
79
|
|
|
// now enable to define controllers without setting it manually. |
80
|
|
|
// So you can comment line 79 if the said instance was enabled. |
81
|
|
|
|
82
|
|
|
// $this->writable->set(GreetController::class, new GreetController); |
|
|
|
|
83
|
6 |
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Returns the writable container. |
87
|
|
|
* |
88
|
|
|
* @return \Zapheus\Container\WritableInterface |
89
|
|
|
*/ |
90
|
6 |
|
public function container() |
91
|
|
|
{ |
92
|
6 |
|
return $this->writable; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Prepares the providers and runs the application. |
97
|
|
|
* |
98
|
|
|
* @return \Zapheus\Application\ApplicationInterface |
99
|
|
|
*/ |
100
|
6 |
|
public function initialize() |
101
|
|
|
{ |
102
|
|
|
// Loads the writable container. |
103
|
6 |
|
$container = $this->container(); |
104
|
|
|
|
105
|
|
|
// Sets up the application with the container |
106
|
6 |
|
$app = new Application($container); |
107
|
|
|
|
108
|
|
|
// Loads all the available providers |
109
|
6 |
|
return $this->providers($app); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Finds an entry of the container by its identifier and returns it. |
114
|
|
|
* |
115
|
|
|
* @param string $id |
116
|
|
|
* @return mixed |
117
|
|
|
* |
118
|
|
|
* @throws \Zapheus\Container\Exception\NotFoundException |
119
|
|
|
* @throws \Zapheus\Container\Exception\ContainerException |
120
|
|
|
*/ |
121
|
6 |
|
public static function make($id) |
122
|
|
|
{ |
123
|
6 |
|
return self::$container->get($id); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Loads the configuration files from a specified path. |
128
|
|
|
* |
129
|
|
|
* @return \Zapheus\Container\WritableContainer |
|
|
|
|
130
|
|
|
*/ |
131
|
6 |
|
protected function configuration() |
132
|
|
|
{ |
133
|
6 |
|
$interface = (string) FrameworkProvider::CONFIG; |
134
|
|
|
|
135
|
6 |
|
$config = new Configuration; |
136
|
|
|
|
137
|
6 |
|
$config->load($this->root . $this->config, true); |
|
|
|
|
138
|
|
|
|
139
|
6 |
|
return $this->writable->set($interface, $config); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* Sets the providers for the application. |
144
|
|
|
* |
145
|
|
|
* @param \Zapheus\Application $application |
146
|
|
|
* @return \Zapheus\Application |
147
|
|
|
*/ |
148
|
6 |
|
protected function providers(Application $application) |
149
|
|
|
{ |
150
|
6 |
|
$config = $application->get(Application::CONFIGURATION); |
151
|
|
|
|
152
|
6 |
|
$zapheus = $config->get('app.providers.zapheus'); |
153
|
|
|
|
154
|
6 |
|
foreach ((array) $zapheus as $provider) { |
155
|
6 |
|
$string = is_string($provider); |
156
|
|
|
|
157
|
6 |
|
$string && $provider = new $provider; |
158
|
|
|
|
159
|
6 |
|
$application->add($provider); |
160
|
6 |
|
} |
161
|
|
|
|
162
|
6 |
|
if (class_exists(self::ILLUMINATE_PROVIDER) === true) { |
163
|
|
|
$laravel = $config->get('app.providers.laravel', array()); |
164
|
|
|
|
165
|
|
|
$application->add(new IlluminateProvider($laravel)); |
166
|
|
|
|
167
|
|
|
$container = $application->get(self::ILLUMINATE_CONTAINER); |
168
|
|
|
|
169
|
|
|
Facade::setFacadeApplication($container); |
170
|
|
|
} |
171
|
|
|
|
172
|
6 |
|
$application->add(new FrameworkProvider($this)); |
173
|
|
|
|
174
|
6 |
|
return static::$container = $application; |
175
|
|
|
} |
176
|
|
|
} |
177
|
|
|
|
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