Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ The keys mirror the command options: `php` applies to every command, and the `pa

## Managed PHP

SKERNEL runs and packages a project with a static PHP build of its own rather than with the PHP on your system. A PHP version is given as `major.minor`, such as `8.4`, which selects that branch's latest release on php.net, or as `major.minor.patch`, such as `8.4.27`. Without a version, SKERNEL selects the latest supported PHP release that satisfies the root package's `require.php`.
SKERNEL builds, runs, and packages a project with a static PHP build of its own rather than with the PHP on your system. A PHP version is given as `major.minor`, such as `8.4`, which selects that branch's latest release on php.net, or as `major.minor.patch`, such as `8.4.27`. Without a version, SKERNEL selects the latest supported PHP release that satisfies the root package's `require.php`.

The build contains the PHP extensions that the project's installation requires through `ext-*` requirements in the root manifest, in its development requirements when they are installed, and in every installed package, together with `phar`. SKERNEL builds it once per platform, version, and extension set with a pinned release of [static-php-cli](https://github.com/crazywhalecc/static-php-cli), producing a static PHP CLI and a micro runtime for standalone binaries, and reuses it afterwards. The micro runtime reports `cli` as `PHP_SAPI`, so a standalone binary starts what requires the CLI, such as a Swoole server. On Linux, both are linked statically against musl and compiled for the architecture's baseline CPU, so they do not depend on the Linux distribution; SKERNEL builds them with a pinned release of [Zig](https://ziglang.org), which it verifies and installs into its home on first use. As the Zig Software Foundation asks of tools, Zig is downloaded from the [community mirrors](https://ziglang.org/download/community-mirrors/) in random order, moving on from a mirror that is too slow, and from ziglang.org only when no mirror serves it.
The build contains the PHP extensions that the project's installation requires through `ext-*` requirements in the root manifest, in its development requirements when they are installed, and in every installed package, together with `phar`, which packaging needs, and `tokenizer`, which `build` needs. SKERNEL builds it once per platform, version, and extension set with a pinned release of [static-php-cli](https://github.com/crazywhalecc/static-php-cli), producing a static PHP CLI and a micro runtime for standalone binaries, and reuses it afterwards. The micro runtime reports `cli` as `PHP_SAPI`, so a standalone binary starts what requires the CLI, such as a Swoole server. On Linux, both are linked statically against musl and compiled for the architecture's baseline CPU, so they do not depend on the Linux distribution; SKERNEL builds them with a pinned release of [Zig](https://ziglang.org), which it verifies and installs into its home on first use. As the Zig Software Foundation asks of tools, Zig is downloaded from the [community mirrors](https://ziglang.org/download/community-mirrors/) in random order, moving on from a mirror that is too slow, and from ziglang.org only when no mirror serves it.

When the installation limits the version of `ext-swoole` or `ext-redis`, through a requirement or a conflict, SKERNEL builds the latest stable PECL release that it accepts. Any other extension is built at the version static-php-cli selects, and a build that ends up with an extension version the installation does not accept fails instead of being used.

Expand Down Expand Up @@ -182,12 +182,12 @@ The newest tag is always the [latest release](https://github.com/super-kernel/sk

## Requirements

- PHP `>=8.4.27 <8.5` with the `openssl`, `pcntl`, `phar`, and `zlib` extensions, only to run SKERNEL from source; Composer checks the required PHP extensions during installation.
- PHP `>=8.4.27 <8.5` with the `openssl`, `pcntl`, `phar`, `tokenizer`, and `zlib` extensions, only to run SKERNEL from source; Composer checks the required PHP extensions during installation.
- Network access and static-php-cli's build tools the first time a managed PHP is built, as described under [Managed PHP](#managed-php).

## Running from source

To work on SKERNEL itself, run it from a clone of this repository. SuperKernel detects an application's root from the working directory, so start SKERNEL from its own directory and select the project to work on with `-d`:
To work on SKERNEL itself, run it from a clone of this repository. Every start from source first generates SKERNEL's own build artifacts in its `vendor/.cache`, the way `build` does for a project, so a change to SKERNEL's sources takes effect at the next start; two starts from the same clone wait for each other while one of them generates. SKERNEL can be started from any directory and works on the project in the current directory, or in the one given with `-d`:

```bash
git clone https://github.com/super-kernel/skernel.git
Expand Down
8 changes: 4 additions & 4 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ SKERNEL 把 WARNING 及以上级别的日志(包括框架的异常报告)写

## 受管 PHP

SKERNEL 用自己构建的静态 PHP 来运行和打包项目,而不是系统上的 PHP。PHP 版本写成 `major.minor`(例如 `8.4`)时,选用 php.net 上该分支的最新发布;写成 `major.minor.patch`(例如 `8.4.27`)时精确使用该版本。不指定版本时,SKERNEL 选用满足根包 `require.php` 的最新受支持 PHP 版本。
SKERNEL 用自己构建的静态 PHP 来构建、运行和打包项目,而不是系统上的 PHP。PHP 版本写成 `major.minor`(例如 `8.4`)时,选用 php.net 上该分支的最新发布;写成 `major.minor.patch`(例如 `8.4.27`)时精确使用该版本。不指定版本时,SKERNEL 选用满足根包 `require.php` 的最新受支持 PHP 版本。

构建出的 PHP 包含项目安装所需的扩展,也就是根清单中、已安装时的开发依赖中,以及每个已安装包中的 `ext-*` 要求,另外再加上 `phar`。SKERNEL 使用固定版本的 [static-php-cli](https://github.com/crazywhalecc/static-php-cli),按平台、版本和扩展组合各构建一次,产出静态 PHP CLI 和用于独立二进制的 micro 运行时,之后重复使用。micro 运行时把 `PHP_SAPI` 报告为 `cli`,所以独立二进制可以启动要求 CLI 的功能,例如 Swoole 服务。在 Linux 上,两者都静态链接 musl,并按该架构的基线 CPU 编译,不依赖具体的 Linux 发行版;SKERNEL 用固定版本的 [Zig](https://ziglang.org) 构建它们,首次使用时校验并安装到自己的主目录中。按照 Zig 软件基金会对下载工具的要求,Zig 以随机顺序从[社区镜像](https://ziglang.org/download/community-mirrors/)下载,某个镜像太慢就换下一个,没有镜像能提供时才从 ziglang.org 下载。
构建出的 PHP 包含项目安装所需的扩展,也就是根清单中、已安装时的开发依赖中,以及每个已安装包中的 `ext-*` 要求,另外再加上打包所需的 `phar` 和 `build` 所需的 `tokenizer`。SKERNEL 使用固定版本的 [static-php-cli](https://github.com/crazywhalecc/static-php-cli),按平台、版本和扩展组合各构建一次,产出静态 PHP CLI 和用于独立二进制的 micro 运行时,之后重复使用。micro 运行时把 `PHP_SAPI` 报告为 `cli`,所以独立二进制可以启动要求 CLI 的功能,例如 Swoole 服务。在 Linux 上,两者都静态链接 musl,并按该架构的基线 CPU 编译,不依赖具体的 Linux 发行版;SKERNEL 用固定版本的 [Zig](https://ziglang.org) 构建它们,首次使用时校验并安装到自己的主目录中。按照 Zig 软件基金会对下载工具的要求,Zig 以随机顺序从[社区镜像](https://ziglang.org/download/community-mirrors/)下载,某个镜像太慢就换下一个,没有镜像能提供时才从 ziglang.org 下载。

当项目安装通过要求或冲突限制了 `ext-swoole` 或 `ext-redis` 的版本时,SKERNEL 会构建它接受的最新 PECL 稳定版。其他扩展使用 static-php-cli 选择的版本;如果构建出的扩展版本不被项目安装接受,构建会失败,而不是继续使用。

Expand Down Expand Up @@ -182,12 +182,12 @@ Package written to /path/to/my-app/target/my-app.

## 环境要求

- PHP `>=8.4.27 <8.5`,并带有 `openssl`、`pcntl`、`phar` 和 `zlib` 扩展,仅在从源码运行 SKERNEL 时需要;安装时由 Composer 检查所需的 PHP 扩展。
- PHP `>=8.4.27 <8.5`,并带有 `openssl`、`pcntl`、`phar`、`tokenizer` 和 `zlib` 扩展,仅在从源码运行 SKERNEL 时需要;安装时由 Composer 检查所需的 PHP 扩展。
- 首次构建受管 PHP 时需要联网,以及 static-php-cli 的构建工具,详见[受管 PHP](#受管-php)。

## 从源码运行

要开发 SKERNEL 本身,请从本仓库的克隆中运行它。SuperKernel 根据工作目录识别应用的根目录,所以请在 SKERNEL 自己的目录中启动它,再用 `-d` 选择要处理的项目:
要开发 SKERNEL 本身,请从本仓库的克隆中运行它。每次从源码启动时,SKERNEL 都会像 `build` 为项目所做的那样,先在自己的 `vendor/.cache` 中生成自己的构建产物,所以对 SKERNEL 源码的修改在下次启动时生效;同一个克隆的两次启动在其中一次生成期间会互相等待。SKERNEL 可以在任意目录中启动,处理当前目录中的项目,或 `-d` 指定的目录中的项目:

```bash
git clone https://github.com/super-kernel/skernel.git
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"ext-openssl": "*",
"ext-pcntl": "*",
"ext-phar": "*",
"ext-tokenizer": "*",
"ext-zlib": "*",
"composer/semver": "^3.6.0",
"psr/log": "^3.0.2",
Expand Down
70 changes: 12 additions & 58 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/Toolchain/Extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
*
* The root manifest's requirements, its development requirements when they are installed, and the requirements of
* every installed package count, as do the conflicts of the root manifest and of every installed package. Extensions
* compiled into every PHP build are left out; phar is always included, because packaging and packaged applications
* need it.
* compiled into every PHP build are left out. phar is always included, because packaging and packaged applications
* need it, and so is tokenizer, because the build generator maps classes with it.
*/
final class Extensions
{
Expand Down Expand Up @@ -89,6 +89,7 @@ public static function required(Project $project): ExtensionRequirements
};
$names = [
'phar',
'tokenizer',
];
$constraints = [];

Expand Down
1 change: 1 addition & 0 deletions tests/Integration/PackageCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ protected function setUp(): void
new ExtensionVersions(new DailyCache(new Home())),
)->directory($this->version, new ExtensionRequirements([
'phar',
'tokenizer',
]));
} finally {
putenv('SKERNEL_HOME');
Expand Down
1 change: 1 addition & 0 deletions tests/Integration/ProjectCommandsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ protected function setUp(): void
new ExtensionVersions(new DailyCache(new Home())),
)->directory($this->version, new ExtensionRequirements([
'phar',
'tokenizer',
]));
} finally {
putenv('SKERNEL_HOME');
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Toolchain/ExtensionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function testCollectsTheVersionsThatTheInstallationAccepts(): void
'pcntl',
'phar',
'swoole',
'tokenizer',
], $extensions->names);
self::assertSame([
'swoole' => [
Expand Down