generated from biurad/php-framework
-
Notifications
You must be signed in to change notification settings - Fork 1
/
flange
40 lines (33 loc) · 1.6 KB
/
flange
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
#!/usr/bin/env php
<?php
/**
* --------------------------------------------------------------------------
* Launch ConsoleApp |
* --------------------------------------------------------------------------.
*
* Let's call the Console-App from index.php file in the public directory
*/
if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
echo 'Warning: The console should be invoked via the CLI version of PHP, not the ' . \PHP_SAPI . ' SAPI' . \PHP_EOL;
}
if (!\file_exists(__DIR__ . '/vendor/autoload.php') && \function_exists('system')) {
// Before we can even start, we need to run composer first
if (!\function_exists('shell_exec')) {
throw new RuntimeException('Please do run \'composer install\' to use this application');
}
// check for global composer install
$path = 0 === \stripos(\PHP_OS, 'win') ? (null !== \shell_exec('composer info') ? 'composer' : '') : \trim(\shell_exec('command -v composer'));
// fallback to download composer.phar
if (!$path || !\preg_match('/(composer|composer\.phar)$/', $path)) {
\shell_exec('curl -s https://getcomposer.org/installer | php');
$path = 'php composer.phar';
}
echo "Preparing to install vendor dependencies...\n\n";
echo \system($path . ' --no-interaction -o install');
echo "\n\n";
}
if (\version_compare($ver = \PHP_VERSION, $req = '8.0', '<')) {
exit(\sprintf("You are running PHP %s, but Application needs at least PHP %s to run.\n", $ver, $req));
}
// Let's initialise console application
require __DIR__ . '/public/index.php';