mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-13 03:45:37 +08:00
Compare commits
3 Commits
2.0.0
...
12ea3218e8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12ea3218e8 | ||
|
|
f9e7af1c9a | ||
|
|
8d2f6baaa2 |
@@ -4,7 +4,7 @@ Build single static PHP binary, with PHP project together, with popular extensio
|
|||||||
|
|
||||||
🌐 **[中文](README-zh.md)** | **[English](README.md)**
|
🌐 **[中文](README-zh.md)** | **[English](README.md)**
|
||||||
|
|
||||||
> 2.0 Release is coming soon, windows support will be added in v2.1.
|
> Windows support will be added in v2.1.
|
||||||
|
|
||||||
The project name is static-php-cli, but it actually supports cli, fpm, micro and embed SAPI 😎
|
The project name is static-php-cli, but it actually supports cli, fpm, micro and embed SAPI 😎
|
||||||
|
|
||||||
|
|||||||
@@ -209,4 +209,21 @@ class SystemUtil
|
|||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get fully-supported linux distros.
|
||||||
|
*
|
||||||
|
* @return string[] List of supported Linux distro name for doctor
|
||||||
|
*/
|
||||||
|
public static function getSupportedDistros(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
// debian-like
|
||||||
|
'debian', 'ubuntu', 'Deepin',
|
||||||
|
// rhel-like
|
||||||
|
'redhat',
|
||||||
|
// alpine
|
||||||
|
'alpine',
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,7 +188,8 @@ class DownloadCommand extends BaseCommand
|
|||||||
// create downloads
|
// create downloads
|
||||||
try {
|
try {
|
||||||
if (PHP_OS_FAMILY !== 'Windows') {
|
if (PHP_OS_FAMILY !== 'Windows') {
|
||||||
f_passthru('mkdir ' . DOWNLOAD_PATH . ' && cd ' . DOWNLOAD_PATH . ' && unzip ' . escapeshellarg($path));
|
$abs_path = realpath($path);
|
||||||
|
f_passthru('mkdir ' . DOWNLOAD_PATH . ' && cd ' . DOWNLOAD_PATH . ' && unzip ' . escapeshellarg($abs_path));
|
||||||
}
|
}
|
||||||
// Windows TODO
|
// Windows TODO
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ class LinuxToolCheckList
|
|||||||
'ubuntu',
|
'ubuntu',
|
||||||
'alpine',
|
'alpine',
|
||||||
'redhat',
|
'redhat',
|
||||||
|
'Deepin',
|
||||||
'debian' => CheckResult::fail(implode(', ', $missing) . ' not installed on your system', 'install-linux-tools', [$distro, $missing]),
|
'debian' => CheckResult::fail(implode(', ', $missing) . ' not installed on your system', 'install-linux-tools', [$distro, $missing]),
|
||||||
default => CheckResult::fail(implode(', ', $missing) . ' not installed on your system'),
|
default => CheckResult::fail(implode(', ', $missing) . ' not installed on your system'),
|
||||||
};
|
};
|
||||||
@@ -70,7 +71,7 @@ class LinuxToolCheckList
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @noinspection PhpUnused */
|
/** @noinspection PhpUnused */
|
||||||
#[AsCheckItem('if necessary packages are installed', limit_os: 'Linux')]
|
#[AsCheckItem('if necessary linux headers are installed', limit_os: 'Linux')]
|
||||||
public function checkSystemOSPackages(): ?CheckResult
|
public function checkSystemOSPackages(): ?CheckResult
|
||||||
{
|
{
|
||||||
if (SystemUtil::isMuslDist()) {
|
if (SystemUtil::isMuslDist()) {
|
||||||
@@ -90,7 +91,7 @@ class LinuxToolCheckList
|
|||||||
public function fixBuildTools(array $distro, array $missing): bool
|
public function fixBuildTools(array $distro, array $missing): bool
|
||||||
{
|
{
|
||||||
$install_cmd = match ($distro['dist']) {
|
$install_cmd = match ($distro['dist']) {
|
||||||
'ubuntu', 'debian' => 'apt-get install -y',
|
'ubuntu', 'debian', 'Deepin' => 'apt-get install -y',
|
||||||
'alpine' => 'apk add',
|
'alpine' => 'apk add',
|
||||||
'redhat' => 'dnf install -y',
|
'redhat' => 'dnf install -y',
|
||||||
default => throw new RuntimeException('Current linux distro does not have an auto-install script for musl packages yet.'),
|
default => throw new RuntimeException('Current linux distro does not have an auto-install script for musl packages yet.'),
|
||||||
@@ -101,7 +102,7 @@ class LinuxToolCheckList
|
|||||||
logger()->warning('Current user is not root, using sudo for running command');
|
logger()->warning('Current user is not root, using sudo for running command');
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$is_debian = in_array($distro['dist'], ['debian', 'ubuntu']);
|
$is_debian = in_array($distro['dist'], ['debian', 'ubuntu', 'Deepin']);
|
||||||
$to_install = $is_debian ? str_replace('xz', 'xz-utils', $missing) : $missing;
|
$to_install = $is_debian ? str_replace('xz', 'xz-utils', $missing) : $missing;
|
||||||
// debian, alpine libtool -> libtoolize
|
// debian, alpine libtool -> libtoolize
|
||||||
$to_install = str_replace('libtoolize', 'libtool', $to_install);
|
$to_install = str_replace('libtoolize', 'libtool', $to_install);
|
||||||
|
|||||||
@@ -13,13 +13,14 @@ class OSCheckList
|
|||||||
{
|
{
|
||||||
use UnixSystemUtilTrait;
|
use UnixSystemUtilTrait;
|
||||||
|
|
||||||
#[AsCheckItem('if current OS are supported', level: 999)]
|
#[AsCheckItem('if current OS are supported', level: 1000)]
|
||||||
public function checkOS(): ?CheckResult
|
public function checkOS(): ?CheckResult
|
||||||
{
|
{
|
||||||
if (!in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'BSD', 'Windows'])) {
|
if (!in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'BSD', 'Windows'])) {
|
||||||
return CheckResult::fail('Current OS is not supported: ' . PHP_OS_FAMILY);
|
return CheckResult::fail('Current OS is not supported: ' . PHP_OS_FAMILY);
|
||||||
}
|
}
|
||||||
$distro = PHP_OS_FAMILY === 'Linux' ? (' ' . SystemUtil::getOSRelease()['dist']) : '';
|
$distro = PHP_OS_FAMILY === 'Linux' ? (' ' . SystemUtil::getOSRelease()['dist']) : '';
|
||||||
return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . $distro . ', supported');
|
$known_distro = PHP_OS_FAMILY === 'Linux' && in_array(SystemUtil::getOSRelease()['dist'], SystemUtil::getSupportedDistros());
|
||||||
|
return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . $distro . ', supported' . ($known_distro ? '' : ' (but not tested on this distro)'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user