mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-04 07:15:38 +08:00
64 lines
11 KiB
JavaScript
64 lines
11 KiB
JavaScript
import{_ as n,c as s,o as e,aj as t}from"./chunks/framework.C2AwuPrQ.js";const g=JSON.parse('{"title":"Project Structure","description":"","frontmatter":{},"headers":[],"relativePath":"en/develop/structure.md","filePath":"en/develop/structure.md"}'),i={name:"en/develop/structure.md"};function p(c,a,l,o,r,d){return e(),s("div",null,[...a[0]||(a[0]=[t(`<h1 id="project-structure" tabindex="-1">Project Structure <a class="header-anchor" href="#project-structure" aria-label="Permalink to “Project Structure”"></a></h1><h2 id="concepts" tabindex="-1">Concepts <a class="header-anchor" href="#concepts" aria-label="Permalink to “Concepts”"></a></h2><p>StaticPHP is a CLI application built on <code>symfony/console</code>, with core code located in the <code>src/StaticPHP</code> directory. It is organized into several modules:</p><ul><li><strong>Registry</strong>: Manages registry data. Each registry contains multiple packages (Package), and the StaticPHP project ships with a built-in <code>core</code> registry that includes PHP and related extensions, dependencies, and more.</li><li><strong>Package</strong>: Represents a single package. There are four package types: <code>php-extension</code> (PHP extension), <code>library</code> (library), <code>target</code> (build target), and <code>virtual-target</code> (virtual build target). Each package contains build information, dependencies, and more.</li><li><strong>Installer/Builder</strong>: Handles installation and build logic for packages — executing build commands, extracting build artifacts, processing build results, etc.</li><li><strong>Doctor</strong>: Provides system environment checking, responsible for installing and verifying system-level dependencies such as <code>make</code>, <code>cmake</code>, <code>autoconf</code>, and more.</li><li><strong>Runtime/Executor</strong>: Contains runtime-related utility classes, such as shell command execution and CMake build execution.</li><li><strong>Toolchain</strong>: Provides toolchain abstraction interfaces for different operating systems and environments, handling system-level differences during the build process.</li><li><strong>Utils</strong>: General-purpose utility classes, such as file system operations, logging, and OS-specific helper methods.</li><li><strong>DependencyResolver</strong>: Resolves dependencies between packages and generates build order.</li></ul><h2 id="directory-layout" tabindex="-1">Directory Layout <a class="header-anchor" href="#directory-layout" aria-label="Permalink to “Directory Layout”"></a></h2><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></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>static-php-cli/</span></span>
|
||
<span class="line"><span>├── bin/ # Executable entry scripts (spc, spc.ps1, setup-runtime, etc.)</span></span>
|
||
<span class="line"><span>├── config/</span></span>
|
||
<span class="line"><span>│ ├── env.ini # Default environment variable configuration</span></span>
|
||
<span class="line"><span>│ ├── env.custom.ini # User-defined environment variables (overrides env.ini)</span></span>
|
||
<span class="line"><span>│ ├── artifact/ # Build artifact configuration (toolchain downloads, pre-built binaries, etc.)</span></span>
|
||
<span class="line"><span>│ └── pkg/ # Package configuration files (YAML)</span></span>
|
||
<span class="line"><span>│ ├── ext/ # PHP extension package config (ext-*.yml, builtin-extensions.yml)</span></span>
|
||
<span class="line"><span>│ ├── lib/ # Library package config (*.yml)</span></span>
|
||
<span class="line"><span>│ └── target/ # Build target config (php.yml, curl.yml, etc.)</span></span>
|
||
<span class="line"><span>├── src/</span></span>
|
||
<span class="line"><span>│ ├── bootstrap.php # Application bootstrap (auto-loading, DI container, etc.)</span></span>
|
||
<span class="line"><span>│ ├── globals/ # Global helper functions</span></span>
|
||
<span class="line"><span>│ ├── Package/ # Build logic implementations for each package (PHP classes)</span></span>
|
||
<span class="line"><span>│ │ ├── Artifact/ # Custom download/extract logic for build artifacts</span></span>
|
||
<span class="line"><span>│ │ ├── Command/ # Package-level custom commands</span></span>
|
||
<span class="line"><span>│ │ ├── Extension/ # PHP extension build classes (ext-*.php)</span></span>
|
||
<span class="line"><span>│ │ ├── Library/ # Library build classes (*.php)</span></span>
|
||
<span class="line"><span>│ │ └── Target/ # Build target classes (php.php, curl.php, etc.)</span></span>
|
||
<span class="line"><span>│ └── StaticPHP/ # Framework core code</span></span>
|
||
<span class="line"><span>│ ├── ConsoleApplication.php # Symfony Console application entry</span></span>
|
||
<span class="line"><span>│ ├── Artifact/ # Build artifact download and extraction (Downloader, Extractor, etc.)</span></span>
|
||
<span class="line"><span>│ ├── Attribute/ # PHP attribute definitions</span></span>
|
||
<span class="line"><span>│ │ ├── Artifact/ # Artifact-related attributes (CustomSource, BinaryExtract, etc.)</span></span>
|
||
<span class="line"><span>│ │ ├── Doctor/ # Doctor-related attributes (CheckItem, FixItem, etc.)</span></span>
|
||
<span class="line"><span>│ │ └── Package/ # Package build-related attributes (BuildFor, BeforeStage, AfterStage,</span></span>
|
||
<span class="line"><span>│ │ # CustomPhpConfigureArg, PatchBeforeBuild, etc.)</span></span>
|
||
<span class="line"><span>│ ├── Command/ # CLI command implementations (build-libs, build-target, doctor, etc.)</span></span>
|
||
<span class="line"><span>│ ├── Config/ # Configuration loading and validation (PackageConfig, ArtifactConfig, etc.)</span></span>
|
||
<span class="line"><span>│ ├── DI/ # Dependency injection container (ApplicationContext, CallbackInvoker, etc.)</span></span>
|
||
<span class="line"><span>│ ├── Doctor/ # System environment checking and fixing (Doctor, CheckResult)</span></span>
|
||
<span class="line"><span>│ ├── Exception/ # Custom exception classes</span></span>
|
||
<span class="line"><span>│ ├── Package/ # Core package models and build scheduling</span></span>
|
||
<span class="line"><span>│ │ ├── Package.php # Base package class</span></span>
|
||
<span class="line"><span>│ │ ├── LibraryPackage.php # Library package type</span></span>
|
||
<span class="line"><span>│ │ ├── PhpExtensionPackage.php # PHP extension package type</span></span>
|
||
<span class="line"><span>│ │ ├── TargetPackage.php # Build target package type</span></span>
|
||
<span class="line"><span>│ │ ├── PackageInstaller.php # Package installer (download, extract source)</span></span>
|
||
<span class="line"><span>│ │ └── PackageBuilder.php # Package builder (execute build pipeline)</span></span>
|
||
<span class="line"><span>│ ├── Registry/ # Registry management (Registry, PackageLoader, ArtifactLoader)</span></span>
|
||
<span class="line"><span>│ ├── Runtime/ # Runtime utilities</span></span>
|
||
<span class="line"><span>│ │ ├── Executor/ # Command executors (UnixAutoconfExecutor, UnixCMakeExecutor,</span></span>
|
||
<span class="line"><span>│ │ │ # WindowsCMakeExecutor, Executor base class)</span></span>
|
||
<span class="line"><span>│ │ ├── Shell/ # Shell abstraction (UnixShell, WindowsCmd, etc.)</span></span>
|
||
<span class="line"><span>│ │ └── SystemTarget.php # System target information</span></span>
|
||
<span class="line"><span>│ ├── Toolchain/ # Toolchain abstraction (GccNative, Musl, MSVC, Zig, ClangBrew, etc.)</span></span>
|
||
<span class="line"><span>│ └── Util/ # General utility classes</span></span>
|
||
<span class="line"><span>│ ├── System/ # OS platform utilities (LinuxUtil, MacOSUtil, WindowsUtil, etc.)</span></span>
|
||
<span class="line"><span>│ ├── BuildRootTracker.php # buildroot file tracking</span></span>
|
||
<span class="line"><span>│ ├── DependencyResolver.php # Dependency resolution and build order</span></span>
|
||
<span class="line"><span>│ ├── FileSystem.php # File system operations</span></span>
|
||
<span class="line"><span>│ ├── GlobalEnvManager.php # Global environment variable management</span></span>
|
||
<span class="line"><span>│ ├── InteractiveTerm.php # Interactive terminal output</span></span>
|
||
<span class="line"><span>│ ├── LicenseDumper.php # License export</span></span>
|
||
<span class="line"><span>│ ├── PkgConfigUtil.php # pkg-config utility wrapper</span></span>
|
||
<span class="line"><span>│ ├── SourcePatcher.php # Source code patching utility</span></span>
|
||
<span class="line"><span>│ └── SPCConfigUtil.php # SPC configuration reader</span></span>
|
||
<span class="line"><span>├── tests/ # Unit tests and integration tests</span></span>
|
||
<span class="line"><span>├── downloads/ # Download cache directory (source packages, pre-built binaries)</span></span>
|
||
<span class="line"><span>├── source/ # Extracted source code directory</span></span>
|
||
<span class="line"><span>├── buildroot/ # Build output directory (headers, static libraries, etc.)</span></span>
|
||
<span class="line"><span>├── pkgroot/ # Platform-archived build artifacts</span></span>
|
||
<span class="line"><span>└── spc.registry.yml # core registry definition file</span></span></code></pre></div><p>Note that the classes in <code>src/Package</code> are responsible for implementing the build logic of specific packages, while the classes in <code>src/StaticPHP</code> provide the core functionality of the build framework, such as command scheduling, environment checking, and toolchain abstraction. The two are decoupled: <code>src/Package</code> corresponds to the packages in the <code>core</code> registry (including PHP, extensions, libraries, and build targets), while <code>src/StaticPHP</code> is the infrastructure that supports build needs across different registries and packages.</p>`,7)])])}const h=n(i,[["render",p]]);export{g as __pageData,h as default};
|