|
2 | 2 | declare(strict_types=1); |
3 | 3 |
|
4 | 4 | use Psr\Container\ContainerInterface; |
5 | | -use SimpleLogger\Stderr; |
6 | 5 |
|
7 | 6 | $root = __DIR__; |
8 | 7 | while (!file_exists($root.'/vendor/autoload.php') && $root != DIRECTORY_SEPARATOR) { |
|
11 | 10 |
|
12 | 11 | require $root.'/vendor/autoload.php'; |
13 | 12 |
|
14 | | -$stderr = new Stderr(); |
15 | | - |
16 | 13 | $file = '/.apiconfig'; |
17 | 14 | $config_file = $root.$file; |
18 | 15 |
|
19 | 16 | if (!file_exists($config_file) || !is_readable($config_file)) { |
20 | | - $stderr->error(".apiconfig file not found"); |
| 17 | + fwrite(STDERR, ".apiconfig file not found"); |
21 | 18 | exit(1); |
22 | 19 | } |
23 | 20 |
|
24 | 21 | $config = json_decode(file_get_contents($config_file), true); |
25 | 22 |
|
26 | 23 | if (JSON_ERROR_NONE !== json_last_error()) { |
27 | | - $stderr->error(".apiconfig contains invalid JSON"); |
| 24 | + fwrite(STDERR, ".apiconfig contains invalid JSON"); |
28 | 25 | exit(1); |
29 | 26 | } |
30 | 27 |
|
|
46 | 43 | $keysInConfig = array_keys($config); |
47 | 44 |
|
48 | 45 | if ($diff = array_diff($keysInConfig, $allKeys)) { |
49 | | - $stderr->error(sprintf( |
| 46 | + fwrite(STDERR, sprintf( |
50 | 47 | 'Found unexpected config keys in .apiconfig: %s', |
51 | 48 | implode(', ', $diff) |
52 | 49 | )); |
|
55 | 52 |
|
56 | 53 | foreach ($required_keys as $required_key) { |
57 | 54 | if (!array_key_exists($required_key, $config)) { |
58 | | - $stderr->error(".apiconfig is missing value for '$required_key'"); |
| 55 | + fwrite(STDERR, ".apiconfig is missing value for '$required_key'"); |
59 | 56 | exit(1); |
60 | 57 | } |
61 | 58 | } |
62 | 59 |
|
63 | 60 | if (array_key_exists('container', $config)) { |
64 | 61 | $file = $config['container']; |
65 | 62 | if (!file_exists($file)) { |
66 | | - $stderr->error(".apiconfig[container] must point to a file returning a PSR-11 container"); |
| 63 | + fwrite(STDERR, ".apiconfig[container] must point to a file returning a PSR-11 container"); |
67 | 64 | exit(1); |
68 | 65 | } |
69 | 66 |
|
|
75 | 72 | try { |
76 | 73 | $container = $load($config['container']); |
77 | 74 | } catch (TypeError $e) { |
78 | | - $stderr->error(".apiconfig[container] must point to a file returning a PSR-11 container"); |
| 75 | + fwrite(STDERR, ".apiconfig[container] must point to a file returning a PSR-11 container"); |
79 | 76 | exit(1); |
80 | 77 | } |
81 | 78 | } |
|
0 commit comments