ILIAS  trunk Revision v13.0_alpha-52-g21c366bbdd4
build_bootstrap.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21require_once(__DIR__ . "/../vendor/composer/vendor/autoload.php");
22
23echo <<<INFO
24Hello there.
25
26This builds the bootstrap of ILIAS by reading all components and resolving the
27dependencies. If you want to use custom directives to resolve ambiguous dependencies,
28call this script with a parameter pointing a file defining the resolution.
29
30
31INFO;
32
33if (count($argv) < 3 || count($argv) % 2 != 1) {
34 die("php cli/build_bootstrap.php \$dependency_resolution \$name [\$another_dependency_resolution \$another_name ...]\n");
35}
36
37array_shift($argv);
38
40 new ILIAS\Component\Dependencies\Mocks\EvalLightMockBuilder()
41);
42
43/******************************************************************************/
44/* Read information from the Components */
45/******************************************************************************/
46
47$component_info = [];
48
49$vendors = new \DirectoryIterator(realpath(__DIR__ . "/../components"));
50echo "Reading Vendors from \"./components\"...\n";
51foreach ($vendors as $vendor) {
52 if (str_starts_with($vendor->getFilename(), ".")) {
53 continue;
54 }
55 if (!$vendor->isDir()) {
56 echo " unexpected non-directory: {$vendor->getPathName()}\n";
57 continue;
58 }
59 echo " Reading Components from Vendor \"{$vendor->getFilename()}\"...\n";
60 $components = new \DirectoryIterator($vendor->getPathName());
61 foreach ($components as $component) {
62 if (str_starts_with($component->getFilename(), ".")) {
63 continue;
64 }
65 if (!$vendor->isDir()) {
66 echo " unexpected non-directory: {$component->getPathName()}\n";
67 continue;
68 }
69 if (!file_exists($component->getPathName() . "/" . $component->getFileName() . ".php")) {
70 echo " expected \"Component.php\" in {$component->getPathName()}\n";
71 continue;
72 }
73 require_once($component->getPathName() . "/" . $component->getFileName() . ".php");
74 $component_name = $vendor->getFilename() . "\\" . $component->getFileName();
75 echo " Reading Component \"$component_name\"...\n";
76 $component_info[] = $reader->read(new $component_name());
77 }
78}
79
80/******************************************************************************/
81/* Resolve and write dependencies for all bootstraps */
82/******************************************************************************/
83
86
87while (count($argv) > 0) {
88 $resolution_file = array_shift($argv);
89 $name = array_shift($argv);
90
91 if (!file_exists($resolution_file)) {
92 die("Cannot find resolution file at {$resolution_file}.\n");
93 }
94
95 echo "Resolving Dependency using {$resolution_file}...\n";
96 $disambiguation = require($resolution_file);
97
98 foreach ($component_info as $ci) {
99 $ci->resetResolutions();
100 }
101 $component_info = $resolver->resolveDependencies($disambiguation, ...$component_info);
102
103 echo "Writing bootstrap to artifacts/bootstrap_$name.php\n";
104
105 $bootstrap = $renderer->render(...$component_info);
106 if (!is_dir(__DIR__ . "/../artifacts")) {
107 mkdir(__DIR__ . "/../artifacts", 0755, true);
108 }
109 file_put_contents(__DIR__ . "/../artifacts/bootstrap_$name.php", $bootstrap);
110}
$components
foreach($components as $component) $resolver
$renderer
This takes a (hopefully resolved...) dependency tree and renders it in PHP to be used for initialisat...
Definition: Renderer.php:28
if(count($argv) !==3) $bootstrap
Definition: entry_point.php:34
to(\GdImage $image, ?int $quality=null)
Currently this is the only way to make a FileStream from a GD image resource.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
Class ilChatroomConfigFileHandler \ILIAS\Chatroom\classes.