static-php-cli/en/faq/index.html

28 lines
27 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>FAQ | static-php-cli</title>
<meta name="description" content="Build single static PHP binary, with PHP project together, with popular extensions included.">
<meta name="generator" content="VitePress v1.2.3">
<link rel="preload stylesheet" href="/assets/style.B_PHkrN1.css" as="style">
<script type="module" src="/assets/app.D3H8Y1BO.js"></script>
<link rel="preload" href="/assets/inter-roman-latin.Di8DUHzh.woff2" as="font" type="font/woff2" crossorigin="">
<link rel="modulepreload" href="/assets/chunks/framework.gjrnbxUT.js">
<link rel="modulepreload" href="/assets/chunks/theme.5IQMzWyn.js">
<link rel="modulepreload" href="/assets/en_faq_index.md.Dk3Q4ZlV.lean.js">
<script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a: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-5d98c3a5><!--[--><!--]--><!--[--><span tabindex="-1" data-v-0f60ec36></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-0f60ec36> Skip to content </a><!--]--><!----><header class="VPNav" data-v-5d98c3a5 data-v-ae24b3ad><div class="VPNavBar top" data-v-ae24b3ad data-v-ccf7ddec><div class="wrapper" data-v-ccf7ddec><div class="container" data-v-ccf7ddec><div class="title" data-v-ccf7ddec><div class="VPNavBarTitle" data-v-ccf7ddec data-v-ab179fa1><a class="title" href="/en/" data-v-ab179fa1><!--[--><!--]--><!----><span data-v-ab179fa1>static-php-cli</span><!--[--><!--]--></a></div></div><div class="content" data-v-ccf7ddec><div class="content-body" data-v-ccf7ddec><!--[--><!--]--><div class="VPNavBarSearch search" data-v-ccf7ddec><!----></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-ccf7ddec data-v-7f418b0f><span id="main-nav-aria-label" class="visually-hidden" data-v-7f418b0f>Main Navigation</span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/en/guide/" tabindex="0" data-v-7f418b0f data-v-9c663999><!--[--><span data-v-9c663999>Guide</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/en/develop/" tabindex="0" data-v-7f418b0f data-v-9c663999><!--[--><span data-v-9c663999>Advanced</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/en/contributing/" tabindex="0" data-v-7f418b0f data-v-9c663999><!--[--><span data-v-9c663999>Contributing</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink active" href="/en/faq/" tabindex="0" data-v-7f418b0f data-v-9c663999><!--[--><span data-v-9c663999>FAQ</span><!--]--></a><!--]--><!--]--></nav><div class="VPFlyout VPNavBarTranslations translations" data-v-ccf7ddec data-v-88af2de4 data-v-b6c34ac9><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="Change language" data-v-b6c34ac9><span class="text" data-v-b6c34ac9><span class="vpi-languages option-icon" data-v-b6c34ac9></span><!----><span class="vpi-chevron-down text-icon" data-v-b6c34ac9></span></span></button><div class="menu" data-v-b6c34ac9><div class="VPMenu" data-v-b6c34ac9 data-v-e7ea1737><!----><!--[--><!--[--><div class="items" data-v-88af2de4><p class="title" data-v-88af2de4>English</p><!--[--><div class="VPMenuLink" data-v-88af2de4 data-v-43f1e123><a class="VPLink link" href="/zh/faq/" data-v-43f1e123><!--[-->简体中文<!--]--></a></div><!--]--></div><!--]--><!--]--></div></div></div><div class="VPNavBarAppearance appearance" data-v-ccf7ddec data-v-e6aabb21><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="Switch to dark theme" aria-checked="false" data-v-e6aabb21 data-v-d1f28634 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-d1f28634></span><span class="vpi-moon moon" data-v-d1f28634></span><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-ccf7ddec data-v-0394ad82 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://github.com/crazywhalecc/static-php-cli" aria-label="github" target="_blank" rel="noopener" data-v-7bc22406 data-v-eee4e7cb><span class="vpi-social-github" /></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-ccf7ddec data-v-d0bd9dde data-v-b6c34ac9><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-b6c34ac9><span class="vpi-more-horizontal icon" data-v-b6c34ac9></span></button><div class="menu" data-v-b6c34ac9><div class="VPMenu" data-v-b6c34ac9 data-v-e7ea1737><!----><!--[--><!--[--><div class="group translations" data-v-d0bd9dde><p class="trans-title" data-v-d0bd9dde>English</p><!--[--><div class="VPMenuLink" data-v-d0bd9dde data-v-43f1e123><a class="VPLink link" href="/zh/faq/" data-v-43f1e123><!--[-->简体中文<!--]--></a></div><!--]--></div><div class="group" data-v-d0bd9dde><div class="item appearance" data-v-d0bd9dde><p
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">bin/spc-gnu-docker</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> build</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ffi,xml</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --build-cli</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --debug</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">buildroot/bin/php</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -d</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;zend_extension=/path/to/php{PHP_VER}-{ts/nts}/xdebug.so&quot;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --ri</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xdebug</span></span></code></pre></div><p>For macOS platform, almost all binaries under macOS cannot be truly purely statically linked, and almost all binaries will link macOS system libraries: <code>/usr/lib/libresolv.9.dylib</code> and <code>/usr/lib/libSystem.B.dylib</code>. So on macOS, you can use statically compiled PHP binaries under certain compilation conditions, and dynamically linked extensions:</p><ol><li>Using the <code>--no-strip</code> parameter will not strip information such as debugging symbols from the binary file for use with external Zend extensions such as <code>Xdebug</code>.</li><li>If you want to compile some Zend extensions, use Homebrew, MacPorts, source code compilation, and install a normal version of PHP on your operating system.</li><li>Use the <code>phpize &amp;&amp; ./configure &amp;&amp; make</code> command to compile the extensions you want to use.</li><li>Copy the extension file <code>xxxx.so</code> to the outside, use the statically compiled PHP binary, for example to use the Xdebug extension: <code>cd buildroot/bin/ &amp;&amp; ./php -d &quot;zend_extension=/path/to/xdebug.so&quot;</code>.</li></ol><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># build statically linked php-cli but not stripped</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">bin/spc</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> build</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ffi</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --build-cli</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --no-strip</span></span></code></pre></div><h2 id="can-it-support-oracle-database-extension" tabindex="-1">Can it support Oracle database extension? <a class="header-anchor" href="#can-it-support-oracle-database-extension" aria-label="Permalink to &quot;Can it support Oracle database extension?&quot;"></a></h2><p>Some extensions that rely on closed source libraries, such as <code>oci8</code>, <code>sourceguardian</code>, etc., they do not provide purely statically compiled dependent library files (<code>.a</code>), only dynamic dependent library files (<code>.so</code>). These extensions cannot be compiled into static-php-cli using source code, so this project may never support these extensions. However, in theory you can access and use such extensions under macOS and Linux according to the above questions.</p><p>If you have a need for such extensions, or most people have needs for these closed-source extensions, see the discussion on <a href="https://github.com/crazywhalecc/static-php-cli/discussions/58" target="_blank" rel="noreferrer">standalone-php-cli</a>. Welcome to leave a message.</p><h2 id="does-it-support-windows" tabindex="-1">Does it support Windows? <a class="header-anchor" href="#does-it-support-windows" aria-label="Permalink to &quot;Does it support Windows?&quot;"></a></h2><p>The project currently supports Windows, but the number of supported extensions is small. Windows support is not perfect. There are mainly the following problems:</p><ol><li>The compilation process of Windows is different from that of *nix, and the toolchain used is also different. The compilation tools used to compile the dependent libraries of each extension are almost completely different.</li><li>The demand for the Windows version will also be advanced based on the needs of all people who use this project. If many people need it, I will support related extensions as soon as possible.</li></ol><h2 id="can-i-protect-my-source-code-with-micro" tabindex="-1">Can I protect my source code with micro? <a class="header-anchor" href="#can-i-protect-my-source-code-with-micro" aria-label="Permalink to &quot;Can I protect my source code with micro?&quot;"></a></h2><p>You can&#39;t. micro.sfx is essentially combining php and php code into one file, there is no process of compiling or encrypting the PHP code.</p><p>First of all, php-src is the official interpreter of PHP code, and there is no PHP compiler compatible with mainstream branches on the market. I saw on the Internet that there is a project called BPC (Binary PHP Compiler?) that can compile PHP into binary, but there are many restrictions.</p><p>The direction of encrypting and protecting the code is not the same as compiling. After compiling, the code can also be obtained through reverse engineering and other methods. The real protection is still carried out by means of packing and encrypting the code.</p><p>Therefore, this project (static-php-cli) and related projects (lwmbs, swoole-cli) all provide a convenient compilation tool for php-src source code. The phpmicro referenced by this project and related projects is only a package of PHP&#39;s sapi interface, not a compilation tool for PHP code. The compiler for PHP code is a completely different project, so the extra cases are not taken into account. If you are interested in encryption, you can consider using existing encryption technologies, such as Swoole Compiler, Source Guardian, etc.</p><h2 id="unable-to-use-ssl" tabindex="-1">Unable to use ssl <a class="header-anchor" href="#unable-to-use-ssl" aria-label="Permalink to &quot;Unable to use ssl&quot;"></a></h2><p><strong>Update: This issue has been fixed in the latest version of static-php-cli, which now re
<script>window.__VP_HASH_MAP__=JSON.parse("{\"en_contributing_index.md\":\"CsY8mx8F\",\"en_develop_php-src-changes.md\":\"DLlooohw\",\"en_develop_system-build-tools.md\":\"D6vaAwN3\",\"en_develop_source-module.md\":\"CdOHR0ez\",\"deps-craft-yml.md\":\"DdOLH9fb\",\"en_develop_doctor-module.md\":\"DGd8PeM_\",\"en_guide_build-on-windows.md\":\"0XosmiyO\",\"en_guide_env-vars.md\":\"CMHjddfB\",\"zh_guide_action-build.md\":\"DWMlBDvT\",\"zh_develop_structure.md\":\"B-0RMSSw\",\"en_guide_build-with-glibc.md\":\"CR2nDLf8\",\"en_guide_action-build.md\":\"BKamBazh\",\"en_guide_cli-generator.md\":\"BVb63i-q\",\"en_develop_index.md\":\"B7_c9YYa\",\"deps-map-lib.md\":\"D13FvK2Q\",\"en_develop_structure.md\":\"BA5PDIse\",\"en_faq_index.md\":\"Dk3Q4ZlV\",\"deps-map-ext.md\":\"CKpfVu5J\",\"en_index.md\":\"Cbpb4iAg\",\"en_guide_extension-notes.md\":\"D_szqpv1\",\"zh_index.md\":\"LslJ1UMp\",\"en_guide_extensions.md\":\"CvNq1b9J\",\"zh_develop_doctor-module.md\":\"DgFAPT6E\",\"zh_guide_extension-notes.md\":\"BwAQ8Pky\",\"zh_develop_system-build-tools.md\":\"Ds53VEw1\",\"zh_guide_cli-generator.md\":\"BQovOB62\",\"zh_guide_build-on-windows.md\":\"BxVEYT8r\",\"zh_guide_deps-map.md\":\"DuTyzThf\",\"zh_guide_env-vars.md\":\"C-N0X5FV\",\"zh_develop_php-src-changes.md\":\"Df0-NcBw\",\"en_develop_craft-yml.md\":\"B3k-Nl-b\",\"en_guide_manual-build.md\":\"BU7HLqGh\",\"zh_develop_source-module.md\":\"D0odLsHX\",\"en_guide_index.md\":\"BScdGPaV\",\"extensions.md\":\"B7vVUihc\",\"en_guide_troubleshooting.md\":\"CTxnPJxK\",\"index.md\":\"mKXtywCA\",\"zh_contributing_index.md\":\"BvgdahxO\",\"zh_guide_extensions.md\":\"HviYRhA7\",\"zh_develop_craft-yml.md\":\"Crgeurk7\",\"zh_develop_index.md\":\"-CPpDfMx\",\"en_guide_deps-map.md\":\"C7t3AggN\",\"zh_faq_index.md\":\"CGJwisr-\",\"zh_guide_build-with-glibc.md\":\"6Wr3xgOs\",\"zh_guide_manual-build.md\":\"Rx1xsyX8\",\"extension-notes.md\":\"Bw8xYOie\",\"zh_guide_index.md\":\"20ged7P4\",\"zh_guide_troubleshooting.md\":\"DAr4n5J3\"}");window.__VP_SITE_DATA__=JSON.parse("{\"lang\":\"en-US\",\"dir\":\"ltr\",\"title\":\"static-php-cli\",\"description\":\"Build single static PHP binary, with PHP project together, with popular extensions included.\",\"base\":\"/\",\"head\":[],\"router\":{\"prefetchLinks\":true},\"appearance\":true,\"themeConfig\":{\"nav\":[],\"socialLinks\":[{\"icon\":\"github\",\"link\":\"https://github.com/crazywhalecc/static-php-cli\"}]},\"locales\":{\"en\":{\"label\":\"English\",\"lang\":\"en\",\"themeConfig\":{\"nav\":[{\"text\":\"Guide\",\"link\":\"/en/guide/\"},{\"text\":\"Advanced\",\"link\":\"/en/develop/\"},{\"text\":\"Contributing\",\"link\":\"/en/contributing/\"},{\"text\":\"FAQ\",\"link\":\"/en/faq/\"}],\"sidebar\":{\"/en/guide/\":[{\"text\":\"Basic Build Guides\",\"items\":[{\"text\":\"Guide\",\"link\":\"/en/guide/\"},{\"text\":\"Build (Local)\",\"link\":\"/en/guide/manual-build\"},{\"text\":\"Build (CI)\",\"link\":\"/en/guide/action-build\"},{\"text\":\"Supported Extensions\",\"link\":\"/en/guide/extensions\"},{\"text\":\"Extension Notes\",\"link\":\"/en/guide/extension-notes\"},{\"text\":\"Build Command Generator\",\"link\":\"/en/guide/cli-generator\"},{\"text\":\"Environment Variables\",\"link\":\"/en/guide/env-vars\",\"collapsed\":true},{\"text\":\"Dependency Table\",\"link\":\"/en/guide/deps-map\"}]},{\"text\":\"Extended Build Guides\",\"items\":[{\"text\":\"Troubleshooting\",\"link\":\"/en/guide/troubleshooting\"},{\"text\":\"Build on Windows\",\"link\":\"/en/guide/build-on-windows\"},{\"text\":\"Build with GNU libc\",\"link\":\"/en/guide/build-with-glibc\"}]}],\"/en/develop/\":[{\"text\":\"Development\",\"items\":[{\"text\":\"Get Started\",\"link\":\"/en/develop/\"},{\"text\":\"Project Structure\",\"link\":\"/en/develop/structure\"},{\"text\":\"PHP Source Modification\",\"link\":\"/en/develop/php-src-changes\"}]},{\"text\":\"Module\",\"items\":[{\"text\":\"Doctor \",\"link\":\"/en/develop/doctor-module\"},{\"text\":\"Source\",\"link\":\"/en/develop/source-module\"}]},{\"text\":\"Extra\",\"items\":[{\"text\":\"Compilation Tools\",\"link\":\"/en/develop/system-build-tools\"
</body>
</html>