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
|
9 |
|
public function __construct($root) |
63
|
|
|
{ |
64
|
9 |
|
$this->root = $root; |
65
|
|
|
|
66
|
9 |
|
$this->writable = new WritableContainer; |
67
|
|
|
|
68
|
9 |
|
$this->configuration(); |
69
|
|
|
|
70
|
|
|
// NOTE: If you want to autowire your classes, you may want |
71
|
|
|
// to use the ReflectionContainer class but it might have an |
72
|
|
|
// effect regarding the performance of the application. Just |
73
|
|
|
// uncomment lines 75 in order to use the mentioned instance. |
74
|
|
|
|
75
|
9 |
|
$this->add(new ReflectionContainer); |
76
|
|
|
|
77
|
|
|
// Define your dependencies below using $this->writable->set() method. |
78
|
|
|
// Documentation: $this->writable->set(string $id, mixed $concrete) |
|
|
|
|
79
|
|
|
|
80
|
|
|
// NOTE: If you enabled the ReflectionContainer above, you can |
81
|
|
|
// now enable to define controllers without setting it manually. |
82
|
|
|
// So you can comment line 84 if the said instance was enabled. |
83
|
|
|
|
84
|
|
|
// $this->writable->set(GreetController::class, new GreetController); |
|
|
|
|
85
|
9 |
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Returns the writable container. |
89
|
|
|
* |
90
|
|
|
* @return \Zapheus\Container\WritableInterface |
91
|
|
|
*/ |
92
|
9 |
|
public function container() |
93
|
|
|
{ |
94
|
9 |
|
return $this->writable; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Prepares the providers and runs the application. |
99
|
|
|
* |
100
|
|
|
* @return \Zapheus\Application\ApplicationInterface |
101
|
|
|
*/ |
102
|
9 |
|
public function initialize() |
103
|
|
|
{ |
104
|
|
|
// Loads the writable container. |
105
|
9 |
|
$container = $this->container(); |
106
|
|
|
|
107
|
|
|
// Sets up the application with the container |
108
|
9 |
|
$app = new Application($container); |
109
|
|
|
|
110
|
|
|
// Loads all the available providers |
111
|
9 |
|
return $this->providers($app); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Finds an entry of the container by its identifier and returns it. |
116
|
|
|
* |
117
|
|
|
* @param string $id |
118
|
|
|
* @return mixed |
119
|
|
|
* |
120
|
|
|
* @throws \Zapheus\Container\Exception\NotFoundException |
121
|
|
|
* @throws \Zapheus\Container\Exception\ContainerException |
122
|
|
|
*/ |
123
|
9 |
|
public static function make($id) |
124
|
|
|
{ |
125
|
9 |
|
return self::$container->get($id); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Loads the configuration files from a specified path. |
130
|
|
|
* |
131
|
|
|
* @return \Zapheus\Container\WritableInterface |
132
|
|
|
*/ |
133
|
9 |
|
protected function configuration() |
134
|
|
|
{ |
135
|
9 |
|
$interface = (string) FrameworkProvider::CONFIG; |
136
|
|
|
|
137
|
9 |
|
$config = new Configuration; |
138
|
|
|
|
139
|
9 |
|
$config->load($this->root . $this->config); |
140
|
|
|
|
141
|
9 |
|
return $this->writable->set($interface, $config); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Sets the providers for the application. |
146
|
|
|
* |
147
|
|
|
* @param \Zapheus\Application $application |
148
|
|
|
* @return \Zapheus\Application |
149
|
|
|
*/ |
150
|
9 |
|
protected function providers(Application $application) |
151
|
|
|
{ |
152
|
9 |
|
$config = $application->get(Application::CONFIGURATION); |
153
|
|
|
|
154
|
9 |
|
$zapheus = $config->get('app.providers.zapheus'); |
155
|
|
|
|
156
|
9 |
|
foreach ((array) $zapheus as $provider) { |
157
|
9 |
|
$string = is_string($provider); |
158
|
|
|
|
159
|
9 |
|
$string && $provider = new $provider; |
160
|
|
|
|
161
|
9 |
|
$application->add($provider); |
162
|
9 |
|
} |
163
|
|
|
|
164
|
|
|
// if (class_exists(self::ILLUMINATE_PROVIDER) === true) { |
|
|
|
|
165
|
|
|
// $laravel = $config->get('app.providers.laravel', array()); |
|
|
|
|
166
|
|
|
|
167
|
|
|
// $application->add(new IlluminateProvider($laravel)); |
|
|
|
|
168
|
|
|
|
169
|
|
|
// $container = $application->get(self::ILLUMINATE_CONTAINER); |
|
|
|
|
170
|
|
|
|
171
|
|
|
// Facade::setFacadeApplication($container); |
|
|
|
|
172
|
|
|
// } |
173
|
|
|
|
174
|
9 |
|
$application->add(new FrameworkProvider($this)); |
175
|
|
|
|
176
|
9 |
|
return static::$container = $application; |
177
|
|
|
} |
178
|
|
|
} |
179
|
|
|
|
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