|
1 | 1 | #!/usr/bin/env php
|
2 | 2 | <?php
|
3 | 3 |
|
4 |
| -use Povils\PHPMND\Console\Application; |
5 |
| -use Povils\PHPMND\Container; |
| 4 | +declare (strict_types=1); |
6 | 5 |
|
7 |
| -if (\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) === false) { |
8 |
| - echo \PHP_EOL . 'PHPMND may only be invoked from a command line, got "' . \PHP_SAPI . '"' . \PHP_EOL; |
9 |
| - |
10 |
| - exit(1); |
11 |
| -} |
12 |
| - |
13 |
| -if (\version_compare('7.4.0', \PHP_VERSION, '>')) { |
14 |
| - \fwrite( |
15 |
| - \STDERR, |
16 |
| - \sprintf( |
17 |
| - 'This version of PHPMND is supported on PHP 7.4.' . \PHP_EOL . |
18 |
| - 'You are using PHP %s%s.' . \PHP_EOL, |
19 |
| - \PHP_VERSION, |
20 |
| - \defined('PHP_BINARY') ? ' (' . \PHP_BINARY . ')' : '' |
21 |
| - ) |
22 |
| - ); |
23 |
| - exit(1); |
| 6 | +if (!file_exists(__DIR__ . '/phpmnd.phar') || is_dir(__DIR__ . '/../vendor')) { |
| 7 | + // Run the internal phpmnd binary directly. |
| 8 | + require __DIR__ . '/phpmnd.src'; |
| 9 | + exit; |
24 | 10 | }
|
25 | 11 |
|
26 |
| -// PHPMND autoloading |
27 |
| -(static function (): void { |
28 |
| - if (\file_exists($autoload = __DIR__ . '/../../../autoload.php')) { |
29 |
| - // Is installed via Composer |
30 |
| - include_once $autoload; |
31 |
| - |
32 |
| - return; |
33 |
| - } |
34 |
| - |
35 |
| - if (\file_exists($autoload = __DIR__ . '/../vendor/autoload.php')) { |
36 |
| - // Is installed locally |
37 |
| - include_once $autoload; |
38 |
| - |
39 |
| - return; |
40 |
| - } |
41 |
| - |
42 |
| - \fwrite( |
43 |
| - \STDERR, |
44 |
| - <<<'ERROR' |
45 |
| -You need to set up the project dependencies using Composer: |
46 |
| - $ composer install |
47 |
| -You can learn all about Composer on https://getcomposer.org/. |
48 |
| -ERROR |
49 |
| - ); |
50 |
| - |
51 |
| - throw new RuntimeException('Unable to find the Composer autoloader.'); |
52 |
| -})(); |
53 |
| - |
54 |
| -// Project (third-party) autoloading |
55 |
| -(static function (): void { |
56 |
| - if (\file_exists($autoload = \getcwd() . '/vendor/autoload.php')) { |
57 |
| - include_once $autoload; |
58 |
| - } |
59 |
| -})(); |
| 12 | +Phar::loadPhar(__DIR__ . '/phpmnd.phar', 'phpmnd.phar'); |
60 | 13 |
|
61 |
| -(new Application(Container::create()))->run(); |
| 14 | +require 'phar://phpmnd.phar/bin/phpmnd.src'; |
0 commit comments