-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpho
More file actions
executable file
·69 lines (52 loc) · 2.5 KB
/
pho
File metadata and controls
executable file
·69 lines (52 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/php
<?php
use Phoundation\Cli\CliCommand;
/**
* Pho ... undation!
*
* This is the standard phoundation command execution script.
*
* With this script you can execute all Phoundation scripts. It supports auto complete so please try and use <TAB>
*
* @author Sven Olaf Oostenbrink <so.oostenbrink@gmail.com>
* @license http://opensource.org/licenses/GPL-2.0 GNU Public License, Version 2
* @copyright Copyright (c) 2022 Sven Olaf Oostenbrink <so.oostenbrink@gmail.com>
* @category Scripts
* @package Phoundation\Cli
*/
try {
// Load the PHP autoloader and execute the static Script::execute() method that will execute the requested command
if (!@include(__DIR__ . '/vendor/autoload.php')) {
throw new Exception('Failed opening required \'./vendor/autoload.php\'');
}
CliCommand::execute();
} catch (Throwable $e) {
$message = $e->getMessage();
if (str_starts_with($message, 'Failed opening required \'./vendor/autoload.php\'')) {
// Whoops, no vendor libraries available. Run composer to fix
echo 'WARNING: Autoloader or vendor libraries could not be found, attempting to fix with composer' . PHP_EOL;
if (file_exists(__DIR__ . '/data/bin/composer.phar')) {
passthru('php ' . __DIR__ . '/data/bin/composer.phar update', $exit_code);
if ($exit_code) {
throw new Exception('Composer failed to execute, see composer output for more information');
}
}else {
echo 'WARNING: Included composer.phar file missing, attempting to run system composer' . PHP_EOL;
$output = exec('which composer');
if ($output) {
passthru($output . ' update', $exit_code);
if ($exit_code) {
throw new Exception('Composer failed to execute, see composer output for more information');
}
} else {
echo 'ERROR: Autoloader and or vendor libraries are missing and failed to find local (./composer.phar) or system composer to try and fix this issue. Please recover the local composer file ./composer.phar or install composer (sudo apt install composer, for example) on your system to retry.' . PHP_EOL;
exit(1);
}
}
echo 'WARNING: Libraries successfully installed, retrying execution of PHO script' . PHP_EOL;
include('./vendor/autoload.php');
CliCommand::execute();
}
// Some other issue occurred, continue throwing exception
throw $e;
}