Skip to main content

Crate mago_prelude

Crate mago_prelude 

Source
Expand description

A crate for building and loading Mago’s “prelude”.

The prelude contains the pre-compiled Database and CodebaseMetadata for all of PHP’s built-in symbols (functions, classes, constants, etc.). This is essential for providing accurate analysis, especially in environments like WASM where stubs cannot be loaded from the filesystem.

§Workflow

This crate is split into two parts using a feature flag:

  1. At Compile Time (with the build feature):

    • A build.rs script enables the build feature for this crate.
    • It calls Prelude::build() to perform the expensive, one-time analysis of all stub files.
    • It then calls prelude.encode() to serialize the result into a byte slice.
    • The bytes are written to a file (e.g., prelude.bin) in the OUT_DIR.
  2. At Runtime (without the build feature):

    • The main application uses include_bytes! to embed the prelude.bin file.
    • It calls Prelude::decode() on the bytes to instantly reconstruct the prelude in memory.

Modules§

error

Structs§

Prelude
A container for the pre-compiled database and metadata of PHP’s built-in symbols.