PHPackages                             syntaxx/webassembly-packer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. syntaxx/webassembly-packer

ActiveProject[Utility &amp; Helpers](/categories/utility)

syntaxx/webassembly-packer
==========================

WebAssembly file packager with LZ4 compression support

v0.1.3(6mo ago)0322MITPHPPHP &gt;=8.1CI passing

Since Oct 26Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/Syntaxx-HQ/PHPX-WebAssemblyPacker)[ Packagist](https://packagist.org/packages/syntaxx/webassembly-packer)[ RSS](/packages/syntaxx-webassembly-packer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (2)

WebAssemblyPacker
=================

[](#webassemblypacker)

A pure PHP implementation of the Emscripten file packager, designed to package and compress files for WebAssembly applications.

Overview
--------

[](#overview)

WebAssemblyPacker is a PHP port of the Emscripten `file_packager.py` script. It provides functionality to package files for WebAssembly applications, including support for preloading, embedding, compression, and caching.

Features
--------

[](#features)

- Pure PHP implementation with no external dependencies
- LZ4 compression support
- File preloading and embedding
- IndexedDB caching support
- Pattern-based file exclusion
- Customizable JavaScript output
- Node.js compatibility options

Installation
------------

[](#installation)

```
composer require syntaxx/webassembly-packer
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
php packer.php data.bin \
    --preload files/ \
    --js-output=output.js \
    --lz4 \
    --use-preload-cache \
    --exclude '*.tmp' \
    --no-node \
    --export-name=createModule
```

### Basic Usage As Library

[](#basic-usage-as-library)

```
use Syntaxx\WebAssemblyPacker\WebAssemblyPacker;
use Syntaxx\WebAssemblyPacker\Options;
use Syntaxx\WebAssemblyPacker\Infra\EventManager;

$eventManager = new EventManager();
$packer = new WebAssemblyPacker($eventManager);
$options = new Options();

// Configure options
$options->jsOutput = 'output.js';
$options->lz4 = true;
$options->usePreloadCache = true;

// Run the packer
$packer->pack($options, ['packer.php', 'data.bin']);
```

### Options

[](#options)

- `--preload`: Specify files or directories to preload
- `--js-output`: Output JavaScript file path
- `--lz4`: Enable LZ4 compression
- `--use-preload-cache`: Enable IndexedDB caching
- `--exclude`: Exclude files matching pattern
- `--no-node`: Disable Node.js specific code
- `--export-name`: Custom export name for the module

### File Path Syntax

[](#file-path-syntax)

#### Basic File Paths

[](#basic-file-paths)

For files within the current working directory, use simple paths:

```
php packer.php data.bin --preload src/main.php
```

#### External File Paths (src@dst syntax)

[](#external-file-paths-srcdst-syntax)

For files outside the current working directory, use the `src@dst` syntax:

```
php packer.php data.bin --preload /tmp/build/main.php@src/main.php
```

This syntax allows you to:

- **Source path** (`src`): Where the actual file is located on your filesystem
- **Destination path** (`dst`): Where that file should appear inside the packed WebAssembly data

**Use cases:**

- Build systems that create files in temporary directories
- Docker containers with different mount points
- CI/CD pipelines with files in different locations
- Cross-platform builds with different path structures

**Example:**

```
# File is in temp directory, but should appear as src/main.php in the package
php packer.php output.data --preload /tmp/phpx-build/.../src/main.php@src/main.php
```

Project Structure
-----------------

[](#project-structure)

```
src/
├── WebAssemblyPacker.php    # Main packer class
├── Options.php             # Configuration options
├── FilesExtractor.php      # File processing
├── DataPacker.php          # Data packaging
├── LZ4Compressor.php       # LZ4 compression
├── DataFile.php            # Data file handling
├── Infra/                  # Infrastructure code
└── JS/                     # JavaScript templates

```

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Composer for dependency management

License
-------

[](#license)

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

Acknowledgments
---------------

[](#acknowledgments)

- Original Emscripten file packager script

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance66

Regular maintenance activity

Popularity7

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

204d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1073586?v=4)[Øystein Kambo Tangerås](/maintainers/kambo)[@kambo](https://github.com/kambo)

---

Top Contributors

[![kambo-1st](https://avatars.githubusercontent.com/u/6493048?v=4)](https://github.com/kambo-1st "kambo-1st (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/syntaxx-webassembly-packer/health.svg)

```
[![Health](https://phpackages.com/badges/syntaxx-webassembly-packer/health.svg)](https://phpackages.com/packages/syntaxx-webassembly-packer)
```

###  Alternatives

[erlandmuchasaj/laravel-gzip

Gzip your responses.

40129.3k2](/packages/erlandmuchasaj-laravel-gzip)[mickgeek/yii2-actionbar

A control bar with bulk actions for the GridView widget.

3444.5k](/packages/mickgeek-yii2-actionbar)[miracuthbert/laravel-royalty

A user points package for Laravel that can be used to give rewards, loyalty or experience points with real time support

825.1k](/packages/miracuthbert-laravel-royalty)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
