Files
static-php-cli/assets/en_guide_installation.md.DNcSrgIL.js
2026-05-11 05:18:54 +00:00

10 lines
17 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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"}'),l={name:"en/guide/installation.md"};function n(h,i,p,d,r,k){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&#39;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&#39;s own build tool.</p></blockquote><div class="vp-code-group"><div class="tabs"><input type="radio" name="group-113" id="tab-114" checked><label data-title="Linux x86_64" for="tab-114">Linux x86_64</label><input type="radio" name="group-113" id="tab-115"><label data-title="Linux arm64" for="tab-115">Linux arm64</label><input type="radio" name="group-113" id="tab-116"><label data-title="macOS x86_64" for="tab-116">macOS x86_64</label><input type="radio" name="group-113" id="tab-117"><label data-title="macOS arm64" for="tab-117">macOS arm64</label><input type="radio" name="group-113" id="tab-118"><label data-title="Windows x86_64" for="tab-118">Windows x86_64</label></div><div class="blocks"><div class="language-shell active"><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:#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></code></pre></div><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:#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></code></pre></div><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:#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></code></pre></div><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:#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></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:#005CC5;--shiki-dark:#79B8FF;">curl.exe</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">#fSL https:</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">//</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">dl.</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">static-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">php.dev</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">/</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">v3</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">/</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">spc</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">bin</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">/</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">nightly</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">/</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">spc-windows-x86_64.exe</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">o </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">spc.exe</span></span></code></pre></div></div></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;"> &amp;&amp; </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&#39;ll need PHP &gt;= 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&#39;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-134" id="tab-135" checked><label data-title="Linux / macOS" for="tab-135">Linux / macOS</label><input type="radio" name="group-134" id="tab-136"><label data-title="Windows" for="tab-136">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>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">runtime/php</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> runtime/composer</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span></span></code></pre></div></li><li><p><strong>Add <code>runtime/</code> to your PATH</strong> so you can use <code>php</code>, <code>composer</code>, and <code>bin/spc</code> without prefixes:</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:#D73A49;--shiki-dark:#F97583;">export</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PATH</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;/path/to/static-php-cli/runtime:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">$PATH</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;</span></span>
<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&#39;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=s(l,[["render",n]]);export{c as __pageData,g as default};