ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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
41/******************************************************************************/
42/* Read information from the Components */
43/******************************************************************************/
44
45$component_info = [];
46
47$vendors = new \DirectoryIterator(realpath(__DIR__ . "/../components"));
48echo "Reading Vendors from \"./components\"...\n";
49foreach ($vendors as $vendor) {
50 if (str_starts_with($vendor->getFilename(), ".")) {
51 continue;
52 }
53 if (!$vendor->isDir()) {
54 echo " unexpected non-directory: {$vendor->getPathName()}\n";
55 continue;
56 }
57 echo " Reading Components from Vendor \"{$vendor->getFilename()}\"...\n";
58 $components = new \DirectoryIterator($vendor->getPathName());
59 foreach ($components as $component) {
60 if (str_starts_with($component->getFilename(), ".")) {
61 continue;
62 }
63 if (!$vendor->isDir()) {
64 echo " unexpected non-directory: {$component->getPathName()}\n";
65 continue;
66 }
67 if (!file_exists($component->getPathName() . "/" . $component->getFileName() . ".php")) {
68 echo " expected \"Component.php\" in {$component->getPathName()}\n";
69 continue;
70 }
71 require_once($component->getPathName() . "/" . $component->getFileName() . ".php");
72 $component_name = $vendor->getFilename() . "\\" . $component->getFileName();
73 echo " Reading Component \"$component_name\"...\n";
74 $component_info[] = $reader->read(new $component_name());
75 }
76}
77
78/******************************************************************************/
79/* Resolve and write dependencies for all bootstraps */
80/******************************************************************************/
81
84
85while (count($argv) > 0) {
86 $resolution_file = array_shift($argv);
87 $name = array_shift($argv);
88
89 if (!file_exists($resolution_file)) {
90 die("Cannot find resolution file at {$resolution_file}.\n");
91 }
92
93 echo "Resolving Dependency using {$resolution_file}...\n";
94 $disambiguation = require($resolution_file);
95
96 foreach ($component_info as $ci) {
97 $ci->resetResolutions();
98 }
99 $component_info = $resolver->resolveDependencies($disambiguation, ...$component_info);
100
101 echo "Writing bootstrap to artifacts/bootstrap_$name.php\n";
102
103 $bootstrap = $renderer->render(...$component_info);
104 if (!is_dir(__DIR__ . "/../artifacts")) {
105 mkdir(__DIR__ . "/../artifacts", 0755, true);
106 }
107 file_put_contents(__DIR__ . "/../artifacts/bootstrap_$name.php", $bootstrap);
108}
$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.