# typephp | Swoole Project | Knowledge Base | Instagit

Compile PHP to Native Binaries

GitHub Stars: 960

Repository: https://github.com/swoole/typephp

---

## Articles

### [How to Specify Conditional Source Entries in `project.yml` Based on PHP Version or OS](/swoole/typephp/typephp-project-yml-conditional-sources)

Learn to conditionally include source entries in project.yml using php version or OS checks. Master version and OS comparisons with the 'if' field for flexible builds.

- Tags: how-to-guide
- Published: 2026-08-30

### [TypePHP `project.yml` Configuration Guide: Complete Manifest Reference](/swoole/typephp/typephp-project-yml-configuration)

Learn how to configure your TypePHP project using the project.yml manifest. This guide covers essential settings like build mode, compiler flags, and source directories for efficient development.

- Tags: api-reference
- Published: 2026-08-30

### [Prerequisites for Building WASM Components with TypePHP: Complete Setup Guide](/swoole/typephp/typephp-wasm-prerequisites)

Learn the prerequisites for building WASM components with TypePHP. Install WASI SDK, add Wasmtime to PATH, and enable Wasm compilation in project.yml for seamless development.

- Tags: how-to-guide
- Published: 2026-08-30

### [How to Compile a TypePHP Project for the Browser Using WebAssembly (WASM)](/swoole/typephp/typephp-compile-browser-wasm)

Compile your TypePHP project for the browser with WebAssembly WASM using our easy three-stage build process. Get started now!

- Tags: how-to-guide
- Published: 2026-08-30

### [How to Compile a TypePHP Project to a WASI Component: Complete Guide](/swoole/typephp/typephp-compile-wasi-component)

Compile your TypePHP project to a WASI component using the TypePhp Platform Wasi abstraction. Learn how to generate portable .wasm binaries with this complete guide.

- Tags: how-to-guide
- Published: 2026-08-30

### [Supported Target Platforms for TypePHP: Windows, Linux, macOS, and WASI](/swoole/typephp/typephp-supported-platforms)

Discover TypePHP's supported target platforms: Windows, Linux, macOS, and WASI. Compile portable binaries easily with automatic host detection and cross-compilation.

- Tags: getting-started
- Published: 2026-08-30

### [What Is the `php_` C++ Symbol Prefix in TypePHP?](/swoole/typephp/typephp-php-symbol-prefix-usage)

Discover the php_ C++ symbol prefix in TypePHP. Learn how it ensures stable, collision-free entry points between PHP and compiled C++ code for user-defined functions and methods.

- Tags: internals
- Published: 2026-08-30

### [How to Integrate C++ Code with TypePHP Projects: A Complete Guide to External Import Stubs](/swoole/typephp/typephp-cpp-php-interoperability)

Integrate C++ with TypePHP using external import stubs. Declare extern functions in PHP, implement in C++, and compile easily. A complete guide for developers.

- Tags: how-to-guide
- Published: 2026-08-30

### [TypePHP Compile-Time Attributes: Supported Registry and Code Generation Explained](/swoole/typephp/typephp-compile-time-attributes-generated-apis)

Discover TypePHP's 18 compile-time attributes like Getter and NotNull. Learn how they generate accessor methods, runtime checks, and WebAssembly exports during compilation.

- Tags: deep-dive
- Published: 2026-08-30

### [How TypePHP Resolves Universal Methods at Compile Time: Static Dispatch in Swoole's PHP Compiler](/swoole/typephp/typephp-universal-methods-compile-time-resolution)

Discover how TypePHP uses static dispatch to resolve universal methods at compile time. Learn how this technique eliminates runtime overhead for functions like length() and upper() in Swoole's PHP compiler.

- Tags: internals
- Published: 2026-08-30

### [TypePHP `std::array` vs PHP Array Performance: How the AOT Compiler Achieves 10x Speedup](/swoole/typephp/typephp-std-array-performance-php-array)

Discover how TypePHP std::array outperforms PHP arrays by 10x. Learn how AOT compilation and native C++ arrays eliminate overhead for blazing fast performance.

- Tags: performance
- Published: 2026-08-30

### [What Are std Containers in TypePHP and Why Use Them Over PHP Arrays](/swoole/typephp/typephp-std-containers-vs-php-arrays)

Discover TypePHP's std containers like std::vector and std::map. Gain compile-time type safety and up to 10x performance gains over PHP arrays by eliminating zval overhead. Learn why they are superior.

- Tags: deep-dive
- Published: 2026-08-30

### [Does TypePHP Automatically Wrap Long Numeric Literals into High-Precision Types?](/swoole/typephp/typephp-auto-wrap-numeric-literals)

Discover if TypePHP wraps long numeric literals into high-precision types. Learn how TypePHP automatically promotes numbers exceeding 64-bit integer limits to BigInt, Decimal, or BigFloat.

- Tags: deep-dive
- Published: 2026-08-30

### [How TypePHP Handles High-Precision Numeric Types: BigInt, Decimal, and BigFloat](/swoole/typephp/typephp-high-precision-numeric-types)

Discover how TypePHP's BigInt, Decimal, and BigFloat classes deliver arbitrary-precision arithmetic using GMP and BCMath, preventing precision loss with strict compile-time checks.

- Tags: deep-dive
- Published: 2026-08-30

### [C++ Equivalents for PHP Scalar Types When Using `use native_types` in TypePHP](/swoole/typephp/typephp-php-to-cpp-scalar-types)

Discover C++ equivalents for PHP scalar types with TypePHP's native_types. Learn how int, float, and bool map to C++ for optimal performance and explore high-precision type handling.

- Tags: deep-dive
- Published: 2026-08-30

### [How TypePHP Handles Native Types with `use native_types`](/swoole/typephp/typephp-native-types-usage)

Discover how TypePHP handles native types using use native_types. Learn how it eliminates zval boxing by mapping PHP scalars to C++ ABI types for efficient compilation.

- Tags: internals
- Published: 2026-08-30

### [When Is `main()` Required for a TypePHP Build? Executable vs Library Guide](/swoole/typephp/typephp-main-function-requirement)

Learn when TypePHP's main() function is essential for executable builds versus library and test targets. Understand TypePHP compilation requirements.

- Tags: how-to-guide
- Published: 2026-08-30

### [TypePHP Compilation Modes Explained: bin, lib, and ext](/swoole/typephp/typephp-compilation-modes-flags)

Understand TypePHP compilation modes bin, lib, and ext. Learn how to build standalone executables, shared libraries, or PHP extensions with the -m flag for your projects.

- Tags: deep-dive
- Published: 2026-08-30

### [TypePHP `--dry` Mode: Generate C++ Without Compiling](/swoole/typephp/typephp-dry-mode-functionality)

Explore TypePHP's --dry mode to generate C++ source files from PHP without compilation. Inspect intermediate .cpp files and understand your code's C++ representation.

- Tags: how-to-guide
- Published: 2026-08-30

### [How TypePHP Achieves Deterministic Multi-File and Self-Hosted Builds](/swoole/typephp/typephp-deterministic-builds)

Learn how TypePHP ensures deterministic multi-file and self-hosted builds by separating analysis and generation. Get predictable results every time.

- Tags: internals
- Published: 2026-08-30

### [TypePHP Compilation Pipeline Phases Explained: Idle, Prepare, and Convert](/swoole/typephp/typephp-compilation-pipeline-phases)

Explore the TypePHP compilation pipeline's three phases: idle, prepare, and convert. Understand how these stages manage TypePHP's AST construction and code generation for efficient development.

- Tags: deep-dive
- Published: 2026-08-30

### [How the TypePHP Compiler Achieves Self-Hosting: Bootstrap Pipeline and Two-Phase Compilation](/swoole/typephp/how-typephp-compiler-self-hosting)

Discover how TypePHP achieves self-hosting with its pure-PHP bootstrap script and two-phase compilation pipeline. Learn how it compiles PHP source into a native binary.

- Tags: internals
- Published: 2026-08-30

### [TypePHP vs PHP Bytecode Caches and JIT Compilers: How AOT Changes PHP Execution](/swoole/typephp/typephp-vs-bytecode-cache-jit)

Discover TypePHP AOT compilation versus PHP bytecode caches and JIT compilers. TypePHP generates native binaries for faster execution without the Zend interpreter.

- Tags: deep-dive
- Published: 2026-08-30

### [How TypePHP Achieves Native AOT Compilation for PHP: A Deep Dive into the Source Code](/swoole/typephp/how-typephp-achieve-native-aot-compilation-php)

Discover how TypePHP achieves native AOT compilation for PHP by compiling PHP AST to C++ source code and then to standalone executables. Learn the internals of this innovative technology.

- Tags: deep-dive
- Published: 2026-08-30

