<spanclass="line"><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">buildroot/bin/php</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -d</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"zend_extension=/path/to/php{PHP_VER}-{ts/nts}/xdebug.so"</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --ri</span><spanstyle="--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 && ./configure && 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/ && ./php -d "zend_extension=/path/to/xdebug.so"</code>.</li></ol><divclass="language-bash vp-adaptive-theme"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">bash</span><preclass="shiki shiki-themes github-light github-dark vp-code"tabindex="0"><code><spanclass="line"><spanstyle="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># build statically linked php-cli but not stripped</span></span>
<spanclass="line"><spanstyle="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">bin/spc</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> build</span><spanstyle="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ffi</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --build-cli</span><spanstyle="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --no-strip</span></span></code></pre></div><h2id="can-it-support-oracle-database-extension"tabindex="-1">Can it support Oracle database extension? <aclass="header-anchor"href="#can-it-support-oracle-database-extension"aria-label="Permalink to "Can it support Oracle database extension?""></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 <ahref="https://github.com/crazywhalecc/static-php-cli/discussions/58"target="_blank"rel="noreferrer">standalone-php-cli</a>. Welcome to leave a message.</p><h2id="does-it-support-windows"tabindex="-1">Does it support Windows? <aclass="header-anchor"href="#does-it-support-windows"aria-label="Permalink to "Does it support Windows?""></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><h2id="can-i-protect-my-source-code-with-micro"tabindex="-1">Can I protect my source code with micro? <aclass="header-anchor"href="#can-i-protect-my-source-code-with-micro"aria-label="Permalink to "Can I protect my source code with micro?""></a></h2><p>You can'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'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><h2id="unable-to-use-ssl"tabindex="-1">Unable to use ssl <aclass="header-anchor"href="#unable-to-use-ssl"aria-label="Permalink to "Unable to use ssl""></a></h2><p><strong>Update: This issue has been fixed in the latest version of static-php-cli, which now re