mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-07 08:45:40 +08:00
deploy: 4218f2905a
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import{_ as i,c as a,o as t,aj as e}from"./chunks/framework.C2AwuPrQ.js";const c=JSON.parse('{"title":"Installation","description":"","frontmatter":{},"headers":[],"relativePath":"en/guide/installation.md","filePath":"en/guide/installation.md"}'),n={name:"en/guide/installation.md"};function l(h,s,p,d,r,o){return t(),a("div",null,[...s[0]||(s[0]=[e(`<h1 id="installation" tabindex="-1">Installation <a class="header-anchor" href="#installation" aria-label="Permalink to “Installation”"></a></h1><h2 id="requirements" tabindex="-1">Requirements <a class="header-anchor" href="#requirements" aria-label="Permalink to “Requirements”"></a></h2><table tabindex="0"><thead><tr><th>Platform</th><th>Architecture</th><th>Notes</th></tr></thead><tbody><tr><td>Linux</td><td>x86_64, aarch64</td><td>Major distros supported (Alpine, Debian/Ubuntu, RHEL/CentOS, etc.)</td></tr><tr><td>macOS</td><td>x86_64 (Intel), arm64 (Apple Silicon)</td><td>macOS 12 or later</td></tr><tr><td>Windows</td><td>x86_64</td><td>Windows 10 Build 17063 or later</td></tr></tbody></table><div class="tip custom-block"><p class="custom-block-title custom-block-title-default">TIP</p><p>Both glibc-based distros (Debian, Ubuntu, Arch, etc.) and musl-based ones (Alpine) are supported on Linux. The <code>doctor</code> command will detect your environment and guide you through installing the right toolchain if needed.</p></div><p>Pick the installation method that fits your use case:</p><table tabindex="0"><thead><tr><th>Method</th><th>Best for</th></tr></thead><tbody><tr><td>Pre-built binary</td><td>Most users — download and run, no dependencies</td></tr><tr><td>From source</td><td>Contributors, or anyone who needs to modify core build logic</td></tr><tr><td>Vendor mode</td><td>Integrating StaticPHP into an existing PHP project</td></tr></tbody></table><h2 id="pre-built-binary" tabindex="-1">Pre-built binary <a class="header-anchor" href="#pre-built-binary" aria-label="Permalink to “Pre-built binary”"></a></h2><p><code>spc</code> has no runtime dependencies — download the binary for your platform and it's ready to go.</p><blockquote><p>Fun fact: <code>spc</code> itself is a static PHP binary built with StaticPHP. We use StaticPHP to build StaticPHP's own build tool.</p></blockquote><div class="language-shell"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Linux x86_64</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">curl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> -#fSL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://dl.static-php.dev/v3/spc-bin/latest/spc-linux-x86_64</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc</span></span>
|
||||
import{_ as s,c as a,o as t,aj as e}from"./chunks/framework.C2AwuPrQ.js";const c=JSON.parse('{"title":"Installation","description":"","frontmatter":{},"headers":[],"relativePath":"en/guide/installation.md","filePath":"en/guide/installation.md"}'),n={name:"en/guide/installation.md"};function l(h,i,p,d,r,o){return t(),a("div",null,[...i[0]||(i[0]=[e(`<h1 id="installation" tabindex="-1">Installation <a class="header-anchor" href="#installation" aria-label="Permalink to “Installation”"></a></h1><h2 id="requirements" tabindex="-1">Requirements <a class="header-anchor" href="#requirements" aria-label="Permalink to “Requirements”"></a></h2><table tabindex="0"><thead><tr><th>Platform</th><th>Architecture</th><th>Notes</th></tr></thead><tbody><tr><td>Linux</td><td>x86_64, aarch64</td><td>Major distros supported (Alpine, Debian/Ubuntu, RHEL/CentOS, etc.)</td></tr><tr><td>macOS</td><td>x86_64 (Intel), arm64 (Apple Silicon)</td><td>macOS 12 or later</td></tr><tr><td>Windows</td><td>x86_64</td><td>Windows 10 Build 17063 or later</td></tr></tbody></table><div class="tip custom-block"><p class="custom-block-title custom-block-title-default">TIP</p><p>Both glibc-based distros (Debian, Ubuntu, Arch, etc.) and musl-based ones (Alpine) are supported on Linux. The <code>doctor</code> command will detect your environment and guide you through installing the right toolchain if needed.</p></div><p>Pick the installation method that fits your use case:</p><table tabindex="0"><thead><tr><th>Method</th><th>Best for</th></tr></thead><tbody><tr><td>Pre-built binary</td><td>Most users — download and run, no dependencies</td></tr><tr><td>From source</td><td>Contributors, or anyone who needs to modify core build logic</td></tr><tr><td>Vendor mode</td><td>Integrating StaticPHP into an existing PHP project</td></tr></tbody></table><h2 id="pre-built-binary" tabindex="-1">Pre-built binary <a class="header-anchor" href="#pre-built-binary" aria-label="Permalink to “Pre-built binary”"></a></h2><p><code>spc</code> has no runtime dependencies — download the binary for your platform and it's ready to go.</p><blockquote><p>Fun fact: <code>spc</code> itself is a static PHP binary built with StaticPHP. We use StaticPHP to build StaticPHP's own build tool.</p></blockquote><div class="language-shell"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Linux x86_64</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">curl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> -#fSL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://dl.static-php.dev/v3/spc-bin/nightly/spc-linux-x86_64</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Linux arm64</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">curl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> -#fSL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://dl.static-php.dev/v3/spc-bin/latest/spc-linux-aarch64</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">curl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> -#fSL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://dl.static-php.dev/v3/spc-bin/nightly/spc-linux-aarch64</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># macOS x86_64 (Intel)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">curl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> -#fSL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://dl.static-php.dev/v3/spc-bin/latest/spc-macos-x86_64</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">curl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> -#fSL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://dl.static-php.dev/v3/spc-bin/nightly/spc-macos-x86_64</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># macOS arm64 (Apple Silicon)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">curl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> -#fSL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://dl.static-php.dev/v3/spc-bin/latest/spc-macos-aarch64</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">curl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> -#fSL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://dl.static-php.dev/v3/spc-bin/nightly/spc-macos-aarch64</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Windows x86_64 (PowerShell)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">curl.exe</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> -#fSL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://dl.static-php.dev/v3/spc-bin/latest/spc-windows-x86_64.exe</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc.exe</span></span></code></pre></div><p>On Linux and macOS, mark the binary as executable before running it:</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">chmod</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> +x</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> && </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">./spc</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --version</span></span></code></pre></div><h2 id="from-source" tabindex="-1">From source <a class="header-anchor" href="#from-source" aria-label="Permalink to “From source”"></a></h2><p>This is the right path if you want to contribute to StaticPHP, or need to modify the core registry and build scripts. You'll need PHP >= 8.4, Composer, and the <code>mbstring,posix,pcntl,iconv,phar,zlib</code> extensions.</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">git</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> clone</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://github.com/crazywhalecc/static-php-cli.git</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --branch</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> v3</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">curl.exe</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> -#fSL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://dl.static-php.dev/v3/spc-bin/nightly/spc-windows-x86_64.exe</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc.exe</span></span></code></pre></div><p>On Linux and macOS, mark the binary as executable before running it:</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">chmod</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> +x</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> && </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">./spc</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --version</span></span></code></pre></div><h2 id="from-source" tabindex="-1">From source <a class="header-anchor" href="#from-source" aria-label="Permalink to “From source”"></a></h2><p>This is the right path if you want to contribute to StaticPHP, or need to modify the core registry and build scripts. You'll need PHP >= 8.4, Composer, and the <code>mbstring,posix,pcntl,iconv,phar,zlib</code> extensions.</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">git</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> clone</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://github.com/crazywhalecc/static-php-cli.git</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --branch</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> v3</span></span>
|
||||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">cd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> static-php-cli</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">composer</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span></span></code></pre></div><p>If you don't have PHP or Composer installed, use the bundled setup script to install a self-contained runtime:</p><div class="vp-code-group"><div class="tabs"><input type="radio" name="group-128" id="tab-129" checked><label data-title="Linux / macOS" for="tab-129">Linux / macOS</label><input type="radio" name="group-128" id="tab-130"><label data-title="Windows" for="tab-130">Windows</label></div><div class="blocks"><div class="language-bash active"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">bin/setup-runtime</span></span></code></pre></div><div class="language-powershell"><button title="Copy Code" class="copy"></button><span class="lang">powershell</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.\\bin\\setup</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">runtime.ps1</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.\\bin\\setup</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">runtime.ps1 </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">add-path</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # add runtime/ to PATH</span></span></code></pre></div></div></div><p>The script downloads <code>php</code> and <code>composer</code> into a <code>runtime/</code> subdirectory. You then have two options:</p><ol><li><p><strong>Call them directly</strong> (no PATH changes needed):</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">runtime/php</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> bin/spc</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --help</span></span>
|
||||
@@ -15,4 +15,4 @@ import{_ as i,c as a,o as t,aj as e}from"./chunks/framework.C2AwuPrQ.js";const c
|
||||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Add this to ~/.bashrc or ~/.zshrc to make it permanent</span></span></code></pre></div></li></ol><h2 id="vendor-mode" tabindex="-1">Vendor mode <a class="header-anchor" href="#vendor-mode" aria-label="Permalink to “Vendor mode”"></a></h2><p>If you already have a PHP project and want to call StaticPHP's build APIs directly, or use a custom registry to support private libraries and extensions, pull it in as a Composer dependency:</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">composer</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> require</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> crazywhalecc/static-php-cli</span></span></code></pre></div><p>See the <a href="./../develop/extending/">Extending StaticPHP</a> guide for details.</p><h2 id="verify-your-build-environment" tabindex="-1">Verify your build environment <a class="header-anchor" href="#verify-your-build-environment" aria-label="Permalink to “Verify your build environment”"></a></h2><blockquote><p><strong>Vendor mode users can skip this step.</strong></p></blockquote><p>Once installed, run <code>doctor</code> to check that your system has the required build tools (cmake, make, a C compiler, etc.):</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Using the spc binary</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">./spc</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> doctor</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># From source</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">bin/spc</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> doctor</span></span></code></pre></div><p>If anything is missing, <code>--auto-fix</code> will attempt to install it for you:</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">./spc</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> doctor</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --auto-fix</span></span></code></pre></div><p>Once <code>doctor</code> reports everything is good, head over to <a href="./first-build.html">First Build</a>.</p>`,30)])])}const g=i(n,[["render",l]]);export{c as __pageData,g as default};
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">bin/spc</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> doctor</span></span></code></pre></div><p>If anything is missing, <code>--auto-fix</code> will attempt to install it for you:</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">./spc</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> doctor</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --auto-fix</span></span></code></pre></div><p>Once <code>doctor</code> reports everything is good, head over to <a href="./first-build.html">First Build</a>.</p>`,30)])])}const g=s(n,[["render",l]]);export{c as __pageData,g as default};
|
||||
@@ -1 +1 @@
|
||||
import{_ as i,c as a,o as t,aj as e}from"./chunks/framework.C2AwuPrQ.js";const c=JSON.parse('{"title":"Installation","description":"","frontmatter":{},"headers":[],"relativePath":"en/guide/installation.md","filePath":"en/guide/installation.md"}'),n={name:"en/guide/installation.md"};function l(h,s,p,d,r,o){return t(),a("div",null,[...s[0]||(s[0]=[e("",30)])])}const g=i(n,[["render",l]]);export{c as __pageData,g as default};
|
||||
import{_ as s,c as a,o as t,aj as e}from"./chunks/framework.C2AwuPrQ.js";const c=JSON.parse('{"title":"Installation","description":"","frontmatter":{},"headers":[],"relativePath":"en/guide/installation.md","filePath":"en/guide/installation.md"}'),n={name:"en/guide/installation.md"};function l(h,i,p,d,r,o){return t(),a("div",null,[...i[0]||(i[0]=[e("",30)])])}const g=s(n,[["render",l]]);export{c as __pageData,g as default};
|
||||
@@ -1,13 +1,13 @@
|
||||
import{_ as i,c as a,o as t,aj as h}from"./chunks/framework.C2AwuPrQ.js";const o=JSON.parse('{"title":"安装 StaticPHP","description":"","frontmatter":{},"headers":[],"relativePath":"zh/guide/installation.md","filePath":"zh/guide/installation.md"}'),l={name:"zh/guide/installation.md"};function e(n,s,p,k,d,r){return t(),a("div",null,[...s[0]||(s[0]=[h(`<h1 id="安装-staticphp" tabindex="-1">安装 StaticPHP <a class="header-anchor" href="#安装-staticphp" aria-label="Permalink to “安装 StaticPHP”"></a></h1><h2 id="系统要求" tabindex="-1">系统要求 <a class="header-anchor" href="#系统要求" aria-label="Permalink to “系统要求”"></a></h2><table tabindex="0"><thead><tr><th>平台</th><th>架构</th><th>说明</th></tr></thead><tbody><tr><td>Linux</td><td>x86_64、aarch64</td><td>支持主流发行版(Alpine、Debian/Ubuntu、RHEL/CentOS 等)</td></tr><tr><td>macOS</td><td>x86_64 (Intel)、arm64 (Apple Silicon)</td><td>需要 macOS 12 或更高版本</td></tr><tr><td>Windows</td><td>x86_64</td><td>需要 Windows 10 Build 17063 或更高版本</td></tr></tbody></table><div class="tip custom-block"><p class="custom-block-title custom-block-title-default">TIP</p><p>Linux 下,glibc 环境(Debian、Ubuntu、Arch 等)和 musl 环境(Alpine)均受支持。 <code>doctor</code> 命令会自动检测当前环境并在必要时引导安装合适的工具链。</p></div><p>StaticPHP 有多种安装方式,选择适合你的场景:</p><table tabindex="0"><thead><tr><th>方式</th><th>适合谁</th></tr></thead><tbody><tr><td>预编译二进制</td><td>大多数用户,直接下载开箱即用</td></tr><tr><td>从源码安装</td><td>参与开发、或需要修改核心构建逻辑的开发者</td></tr><tr><td>Vendor 模式</td><td>在已有 PHP 项目中集成 StaticPHP 能力</td></tr></tbody></table><h2 id="预编译二进制" tabindex="-1">预编译二进制 <a class="header-anchor" href="#预编译二进制" aria-label="Permalink to “预编译二进制”"></a></h2><p>spc 无须任何依赖,下载即可运行,支持 Linux、macOS 和 Windows。</p><blockquote><p>spc 本身是由 StaticPHP 构建的静态 PHP 二进制,幽默地说:我们用 StaticPHP 构建了 StaticPHP 的构建工具。</p></blockquote><div class="language-shell"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Linux x86_64</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">curl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> -#fSL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://dl.static-php.dev/v3/spc-bin/latest/spc-linux-x86_64</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">curl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> -#fSL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://dl.static-php.dev/v3/spc-bin/nightly/spc-linux-x86_64</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Linux arm64</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">curl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> -#fSL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://dl.static-php.dev/v3/spc-bin/latest/spc-linux-aarch64</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">curl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> -#fSL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://dl.static-php.dev/v3/spc-bin/nightly/spc-linux-aarch64</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># macOS x86_64 (Intel)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">curl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> -#fSL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://dl.static-php.dev/v3/spc-bin/latest/spc-macos-x86_64</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">curl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> -#fSL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://dl.static-php.dev/v3/spc-bin/nightly/spc-macos-x86_64</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># macOS arm64 (Apple Silicon)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">curl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> -#fSL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://dl.static-php.dev/v3/spc-bin/latest/spc-macos-aarch64</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">curl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> -#fSL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://dl.static-php.dev/v3/spc-bin/nightly/spc-macos-aarch64</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Windows x86_64 (PowerShell)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">curl.exe</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> -#fSL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://dl.static-php.dev/v3/spc-bin/latest/spc-windows-x86_64.exe</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc.exe</span></span></code></pre></div><p>*nix 系统下载完成后需要赋予可执行权限:</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">chmod</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> +x</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> && </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">./spc</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --version</span></span></code></pre></div><h2 id="从源码安装" tabindex="-1">从源码安装 <a class="header-anchor" href="#从源码安装" aria-label="Permalink to “从源码安装”"></a></h2><p>适合想参与开发、或需要修改核心注册表和构建脚本的开发者。需要系统已安装 PHP >= 8.4、Composer,以及 <code>mbstring,posix,pcntl,iconv,phar,zlib</code> 扩展。</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">git</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> clone</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://github.com/crazywhalecc/static-php-cli.git</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --branch</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> v3</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">curl.exe</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> -#fSL</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://dl.static-php.dev/v3/spc-bin/nightly/spc-windows-x86_64.exe</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -o</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc.exe</span></span></code></pre></div><p>*nix 系统下载完成后需要赋予可执行权限:</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">chmod</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> +x</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> spc</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> && </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">./spc</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --version</span></span></code></pre></div><h2 id="从源码安装" tabindex="-1">从源码安装 <a class="header-anchor" href="#从源码安装" aria-label="Permalink to “从源码安装”"></a></h2><p>适合想参与开发、或需要修改核心注册表和构建脚本的开发者。需要系统已安装 PHP >= 8.4、Composer,以及 <code>mbstring,posix,pcntl,iconv,phar,zlib</code> 扩展。</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">git</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> clone</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://github.com/crazywhalecc/static-php-cli.git</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --branch</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> v3</span></span>
|
||||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">cd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> static-php-cli</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">composer</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span></span></code></pre></div><p>如果系统还没有 PHP 和 Composer,可以用内置脚本一键安装运行环境:</p><div class="vp-code-group"><div class="tabs"><input type="radio" name="group-128" id="tab-129" checked><label data-title="Linux / macOS" for="tab-129">Linux / macOS</label><input type="radio" name="group-128" id="tab-130"><label data-title="Windows" for="tab-130">Windows</label></div><div class="blocks"><div class="language-bash active"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">bin/setup-runtime</span></span></code></pre></div><div class="language-powershell"><button title="Copy Code" class="copy"></button><span class="lang">powershell</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.\\bin\\setup</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">runtime.ps1</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.\\bin\\setup</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">runtime.ps1 </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">add-path</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 将 runtime/ 加入 PATH</span></span></code></pre></div></div></div><p>脚本执行完成后,会在项目目录下生成 <code>runtime/</code> 子目录,其中包含 <code>php</code> 和 <code>composer</code> 两个可执行文件。安装完成后有两种使用方式:</p><ol><li><p><strong>直接通过路径调用</strong>(无需修改环境变量):</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark" style="--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e;" tabindex="0" dir="ltr"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">runtime/php</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> bin/spc</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --help</span></span>
|
||||
Reference in New Issue
Block a user