Files
static-php-cli/en/guide/installation.html

33 lines
43 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Installation | StaticPHP</title>
<meta name="description" content="A powerful tool designed for building portable executables including PHP, extensions, and more.">
<meta name="generator" content="VitePress v2.0.0-alpha.18">
<link rel="preload stylesheet" href="/assets/style.C4OPn_QV.css" as="style">
<link rel="preload stylesheet" href="/vp-icons.css" as="style">
<script type="module" src="/assets/app.Bw02Lh2k.js"></script>
<link rel="preload" href="/assets/inter-roman-latin.Cy4MYw_J.woff2" as="font" type="font/woff2" crossorigin="">
<link rel="modulepreload" href="/assets/chunks/theme.C_odZu9O.js">
<link rel="modulepreload" href="/assets/chunks/framework.DrNIf5Lg.js">
<link rel="modulepreload" href="/assets/en_guide_installation.md.BV9Ks-lX.lean.js">
<script id="check-dark-mode">(()=>{let e=localStorage.getItem(`vitepress-theme-appearance`)||`auto`,t=window.matchMedia(`(prefers-color-scheme: dark)`).matches;(!e||e===`auto`?t:e===`dark`)&&document.documentElement.classList.add(`dark`)})();</script>
<script id="check-mac-os">document.documentElement.classList.toggle(`mac`,/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
</head>
<body>
<div id="app"><div class="Layout" data-v-0cf61682><!--[--><!--]--><!--[--><span tabindex="-1" data-v-414181b2></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-414181b2>Skip to content</a><!--]--><!----><header class="VPNav" data-v-0cf61682 data-v-9f75dce3><div class="VPNavBar has-sidebar top" data-v-9f75dce3 data-v-9ca1369d><div class="wrapper" data-v-9ca1369d><div class="container" data-v-9ca1369d><div class="title" data-v-9ca1369d><div class="VPNavBarTitle has-sidebar" data-v-9ca1369d data-v-1e38c6bc><a class="title" href="/en/" data-v-1e38c6bc><!--[--><!--]--><!--[--><img class="VPImage logo" src="/images/static-php_nobg.png" alt data-v-8426fc1a><!--]--><span data-v-1e38c6bc>StaticPHP</span><!--[--><!--]--></a></div></div><div class="content" data-v-9ca1369d><div class="content-body" data-v-9ca1369d><!--[--><!--]--><div class="VPNavBarSearch search" data-v-9ca1369d data-v-2fc7f2c6><!--[--><button type="button" class="VPNavBarSearchButton" aria-label="Search" aria-keyshortcuts="/ control+k meta+k" data-v-2fc7f2c6 data-v-baa3be99><span class="vpi-search" aria-hidden="true" data-v-baa3be99></span><span class="text" data-v-baa3be99>Search</span><span class="keys" aria-hidden="true" data-v-baa3be99><kbd class="key-cmd" data-v-baa3be99></kbd><kbd class="key-ctrl" data-v-baa3be99>Ctrl</kbd><kbd data-v-baa3be99>K</kbd></span></button><button type="button" class="VPNavBarAskAiButton" aria-label="Ask AI" aria-keyshortcuts="control+i meta+i" data-v-2fc7f2c6 data-v-4eb17e89><span class="vpi-sparkles" aria-hidden="true" data-v-4eb17e89></span></button><!----><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-9ca1369d data-v-7b3e138d><span id="main-nav-aria-label" class="visually-hidden" data-v-7b3e138d> Main Navigation </span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/en/guide/" tabindex="0" data-v-7b3e138d data-v-6500c4c4><!--[--><span data-v-6500c4c4>Guide</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/en/develop/" tabindex="0" data-v-7b3e138d data-v-6500c4c4><!--[--><span data-v-6500c4c4>Develop</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/en/contributing/" tabindex="0" data-v-7b3e138d data-v-6500c4c4><!--[--><span data-v-6500c4c4>Contributing</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/en/faq/" tabindex="0" data-v-7b3e138d data-v-6500c4c4><!--[--><span data-v-6500c4c4>FAQ</span><!--]--></a><!--]--><!--[--><div class="VPFlyout VPNavBarMenuGroup" data-v-7b3e138d data-v-42cb505d><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-42cb505d><span class="text" data-v-42cb505d><!----><span data-v-42cb505d>v3 (alpha)</span><span class="vpi-chevron-down text-icon" data-v-42cb505d></span></span></button><div class="menu" data-v-42cb505d><div class="VPMenu" data-v-42cb505d data-v-25a6cce8><div class="items" data-v-25a6cce8><!--[--><!--[--><div class="VPMenuLink" data-v-25a6cce8 data-v-fff73daa><a class="VPLink link" href="/en/" data-v-fff73daa><!--[--><span data-v-fff73daa>v3 (alpha)</span><!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-25a6cce8 data-v-fff73daa><a class="VPLink link" href="https://static-php.github.io/v2-docs/" data-v-fff73daa><!--[--><span data-v-fff73daa>v2</span><!--]--></a></div><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--]--></nav><div class="VPFlyout VPNavBarTranslations translations" data-v-9ca1369d data-v-c70a0580 data-v-42cb505d><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="Change language" data-v-42cb505d><span class="text" data-v-42cb505d><span class="vpi-languages option-icon" data-v-42cb505d></span><!----><span class="vpi-chevron-down text-icon" data-v-42cb505d></span></span></button><div class="menu" data-v-42cb505d><div class="VPMenu" data-v-42cb505d data-v-25a6cce8><!----><!--[--><!--[--><div class="items" data-v-c70a0580><p class="title" data-v-c70a0580>English</p><!--[--><div class="VPMenuLin
<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:#c62739;--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:#c62739;--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:#62687b;--shiki-dark:#818e99;"> # 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:#c62739;--shiki-dark:#F97583;">export</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PATH</span><span style="--shiki-light:#c62739;--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:#62687b;--shiki-dark:#818e99;"># 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:#62687b;--shiki-dark:#818e99;"># 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:#62687b;--shiki-dark:#818e99;"># 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></div></div></main><footer class="VPDocFooter" data-v-7011f0d8 data-v-e29034c6><!--[--><!--]--><!----><nav class="prev-next" aria-labelledby="doc-footer-aria-label" data-v-e29034c6><span class="visually-hidden" id="doc-footer-aria-label" data-v-e29034c6>Pager</span><div class="pager" data-v-e29034c6><a class="VPLink link pager-link prev" href="/en/guide/" data-v-e29034c6><!--[--><span class="desc" data-v-e29034c6>Previous page</span><span class="title" data-v-e29034c6>Overview</span><!--]--></a></div><div class="pager" data-v-e29034c6><a class="VPLink link pager-link next" href="/en/guide/first-build.html" data-v-e29034c6><!--[--><span class="desc" data-v-e29034c6>Next page</span><span class="title" data-v-e29034c6>First Build</span><!--]--></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><footer class="VPFooter has-sidebar" data-v-0cf61682 data-v-c3855bb3><div class="container" data-v-c3855bb3><p class="message" data-v-c3855bb3>Released under the MIT License.</p><p class="copyright" data-v-c3855bb3>Copyright © 2023-present crazywhalecc</p></div></footer><!--[--><!--]--></div></div>
<script>window.__VP_HASH_MAP__=JSON.parse("{\"deps-craft-yml.md\":\"BlUAUDy4\",\"en_contributing_index.md\":\"DJrK0rwl\",\"en_develop_artifact-model.md\":\"CSsy1IGq\",\"en_develop_build-lifecycle.md\":\"DAZqcB7z\",\"en_develop_craft-yml.md\":\"KSoZofRA\",\"en_develop_doctor-module.md\":\"ByvES-_A\",\"en_develop_extending_annotations.md\":\"UKL7B7B3\",\"en_develop_extending_custom-artifact.md\":\"DotD8ITd\",\"en_develop_extending_dependency-injection.md\":\"CyyHOkvH\",\"en_develop_extending_index.md\":\"B2xj8d9p\",\"en_develop_extending_lifecycle-hooks.md\":\"6uwWcfAD\",\"en_develop_extending_package-classes.md\":\"y3Xf7UZ4\",\"en_develop_index.md\":\"BITZJqcR\",\"en_develop_package-model.md\":\"CMZBu01x\",\"en_develop_php-src-changes.md\":\"Cc0fC8cE\",\"en_develop_registry.md\":\"BsjJNDQv\",\"en_develop_structure.md\":\"D8gP8oQJ\",\"en_develop_system-build-tools.md\":\"CUw5wQ4E\",\"en_faq_index.md\":\"BvIAh2aW\",\"en_guide_cli-generator.md\":\"C6SB8xhE\",\"en_guide_cli-reference.md\":\"D7EY77fp\",\"en_guide_deps-map.md\":\"DKgvqXtD\",\"en_guide_env-vars.md\":\"BgjYKJG9\",\"en_guide_extension-notes.md\":\"B3shjkUU\",\"en_guide_extensions.md\":\"ATwZq3HB\",\"en_guide_first-build.md\":\"INdBGOsG\",\"en_guide_index.md\":\"z0D1Gcrs\",\"en_guide_installation.md\":\"BV9Ks-lX\",\"en_guide_migrate-from-v2.md\":\"CUFkYufx\",\"en_guide_sapi-reference.md\":\"p2zEyiLe\",\"en_guide_troubleshooting.md\":\"DVi8H9ZX\",\"en_index.md\":\"D-9tNbNs\",\"index.md\":\"TfAAAF_x\",\"zh_contributing_index.md\":\"8SUl40-w\",\"zh_develop_artifact-model.md\":\"CrLRSeeY\",\"zh_develop_build-lifecycle.md\":\"DLh_YUAK\",\"zh_develop_craft-yml.md\":\"uyL3P4FG\",\"zh_develop_doctor-module.md\":\"B-KVjOyS\",\"zh_develop_extending_annotations.md\":\"Dcz6J_X-\",\"zh_develop_extending_custom-artifact.md\":\"BoYCxDEr\",\"zh_develop_extending_dependency-injection.md\":\"BKeBJfDY\",\"zh_develop_extending_index.md\":\"B7wWMbKy\",\"zh_develop_extending_lifecycle-hooks.md\":\"CG51Rugr\",\"zh_develop_extending_package-classes.md\":\"DBU2hT9_\",\"zh_develop_index.md\":\"CrUwzvi2\",\"zh_develop_package-model.md\":\"DDw9ZCCd\",\"zh_develop_php-src-changes.md\":\"artDuYna\",\"zh_develop_registry.md\":\"ChqnXzVM\",\"zh_develop_structure.md\":\"BivWsi6C\",\"zh_develop_system-build-tools.md\":\"BLdfbezU\",\"zh_faq_index.md\":\"ypwV8ySx\",\"zh_guide_cli-generator.md\":\"BuKsNlwB\",\"zh_guide_cli-reference.md\":\"LVzdkmu2\",\"zh_guide_deps-map.md\":\"9-QWHshB\",\"zh_guide_env-vars.md\":\"D2oUaqNR\",\"zh_guide_extension-notes.md\":\"D9lGXhKW\",\"zh_guide_extensions.md\":\"CNtRfejb\",\"zh_guide_first-build.md\":\"DSwF9CHy\",\"zh_guide_index.md\":\"DR1hBcxc\",\"zh_guide_installation.md\":\"CWZRSBwL\",\"zh_guide_migrate-from-v2.md\":\"Dp7VZbGT\",\"zh_guide_sapi-reference.md\":\"TjYI_FdR\",\"zh_guide_troubleshooting.md\":\"CJ6N_2fk\",\"zh_index.md\":\"BXvgifjq\"}");window.__VP_SITE_DATA__=JSON.parse("{\"lang\":\"en-US\",\"dir\":\"ltr\",\"title\":\"StaticPHP\",\"description\":\"A powerful tool designed for building portable executables including PHP, extensions, and more.\",\"base\":\"/\",\"head\":[],\"router\":{\"prefetchLinks\":true},\"appearance\":true,\"themeConfig\":{\"logo\":\"/images/static-php_nobg.png\",\"nav\":[],\"socialLinks\":[{\"icon\":\"github\",\"link\":\"https://github.com/crazywhalecc/static-php-cli\"}],\"footer\":{\"message\":\"Released under the MIT License.\",\"copyright\":\"Copyright © 2023-present crazywhalecc\"},\"externalLinkIcon\":true,\"search\":{\"provider\":\"algolia\",\"options\":{\"appId\":\"IHJHUB1SF1\",\"apiKey\":\"8266d31cc2ffbd0e059f1c6e5bdaf8fc\",\"indexName\":\"static-php docs\",\"askAi\":{\"assistantId\":\"b72369b2-60a5-461d-902c-5c18d8c05902\",\"agentStudio\":true,\"sidePanel\":true}}}},\"locales\":{\"en\":{\"label\":\"English\",\"lang\":\"en\",\"themeConfig\":{\"nav\":[{\"text\":\"Guide\",\"link\":\"/en/guide/\"},{\"text\":\"Develop\",\"link\":\"/en/develop/\"},{\"text\":\"Contributing\",\"link\":\"/en/contributing/\"},{\"text\":\"FAQ\",\"link\":\"/en/faq/\"},{\"text\":\"v3 (alpha)\",\"items\":[{\"text\":\"v3 (alpha)\",\"link\":\"/en/\
</body>
</html>