import{_ase,caso,oast,a1asc}from"./chunks/framework.gjrnbxUT.js";consty=JSON.parse('{"title":"Introduction to project structure","description":"","frontmatter":{},"headers":[],"relativePath":"en/develop/structure.md","filePath":"en/develop/structure.md"}'),d={name:"en/develop/structure.md"},a=c(`<h1 id="introduction-to-project-structure" tabindex="-1">Introduction to project structure <a class="header-anchor" href="#introduction-to-project-structure" aria-label="Permalink to "Introduction to project structure""></a></h1><p>static-php-cli mainly contains three logical components: sources, dependent libraries, and extensions. These components contains 4 configuration files: <code>source.json</code>, <code>pkg.json</code>, <code>lib.json</code>, and <code>ext.json</code>.</p><p>A complete process for building standalone static PHP is:</p><ol><li>Use the source download module <code>Downloader</code> to download specified or all source codes. These sources include PHP source code, dependent library source code, and extension source code.</li><li>Use the source decompression module <code>SourceExtractor</code> to decompress the downloaded sources to the compilation directory.</li><li>Use the dependency tool to calculate the dependent extensions and dependent libraries of the currently added extension, and then compile each library that needs to be compiled in the order of dependencies.</li><li>After building each dependent library using <code>Builder</code> under the corresponding operating system, install it to the <code>buildroot</code> directory.</li><li>If external extensions are included (the source code does not contain extensions within PHP), copy the external extensions to the <code>source/php-src/ext/</code> directory.</li><li>Use <code>Builder</code> to build the PHP source code and build target to the <code>buildroot</code> directory.</li></ol><p>The project is mainly divided into several folders:</p><ul><li><code>bin/</code>: used to store program entry files, including <code>bin/spc</code>, <code>bin/spc-alpine-docker</code>, <code>bin/setup-runtime</code>.</li><li><code>config/</code>: Contains all the extensions and dependent libraries supported by the project, as well as the download link and download methods of these sources. It is divided into files: <code>lib.json</code>, <code>ext.json</code>, <code>source.json</code>, <code>pkg.json</code>, <code>pre-built.json</code> .</li><li><code>src/</code>: The core code of the project, including the entire framework and commands for compiling various extensions and libraries.</li><li><code>vendor/</code>: The directory that Composer depends on, you do not need to make any modifications to it.</li></ul><p>The operating principle is to start a <code>ConsoleApplication</code> of <code>symfony/console</code>, and then parse the commands entered by the user in the terminal.</p><h2 id="basic-command-line-structure" tabindex="-1">Basic command line structure <a class="header-anchor" href="#basic-command-line-structure" aria-label="Permalink to "Basic command line structure""></a></h2><p><code>bin/spc</code> is an entry file, including the Unix common <code>#!/usr/bin/env php</code>, which is used to allow the system to automatically execute with the PHP interpreter installed on the system. After the project executes <code>new ConsoleApplication()</code>, the framework will automatically register them as commands.</p><p>The project does not directly use the Command registration method and command execution method recommended by Symfony. Here are small changes:</p><ol><li>Each command uses the <code>#[AsCommand()]</code> Attribute to register the name and description.</li><li>Abstract <code>execute()</code> so that all commands are based on <code>BaseCommand</code> (which is based on <code>Symfony\\Component\\Console\\Command\\Command</code>), and the execution code of each command itself is written in the <code>handle()</code> method .</li><li>Added variable <code>$no_motd</code> to <code>BaseCommand</code>, which is used to display the