Skip to content
Phast: Rust-Based PHP Package Manager 3-10x Faster Than Composer

Phast: Rust-Based PHP Package Manager 3-10x Faster Than Composer

Phast is a Rust-written PHP dependency manager that drops in as a Composer replacement, delivering 3-10x speed gains via PubGrub solving, async metadata prefetching, and parallel downloads while supporting composer.json, monorepos, vulnerability auditing, and deterministic lock files.

Open Source Tech Hub
Open Source Tech Hub
Open Source Tech Hub

Introduction

Phast is an extremely fast PHP dependency manager written in Rust. It serves as a drop-in replacement for Composer: it resolves, downloads, and autoloads dependencies from Packagist and any Composer-compatible registry, while introducing a clean TOML-based workflow built on phast.toml and phast.lock. According to the official documentation ( docs.phast.sh), Phast achieves 3-10x speed improvements over Composer with the same composer.json and vendor/ directory.

Compatibility with Existing Composer Ecosystem

No breaking changes required for existing projects:

Native composer.json support : run phast install directly in any PHP project root.

Seamless integration with all mainstream sources : Packagist, Private Packagist, Satis, Git repositories, and local path repositories.

100% runtime compatibility : generates a standard-compliant vendor/autoload.php and fully supports Composer's core \Composer\InstalledVersions class, so existing application code runs unchanged.

Modern TOML Workflow

The official documentation promotes a more modern, human-readable phast.toml manifest:

Retains familiar concepts : keeps Composer core terms ( require, require-dev, autoload) using clear, comment-supporting TOML syntax.

Schema validation and IDE intelligence : provides a unified JSON Schema ( https://phast.sh/schema/v1/manifest.json) for instant validation and autocompletion in IDEs.

One-click smooth migration ( phast migrate ) : built-in command converts existing composer.json losslessly to phast.toml and phast.lock.

Example phast.toml:

#:schema https://phast.sh/schema/v1/manifest.json
[package]
name = "acme/my-app"
description = "My modern PHP application"
type = "project"
license = "MIT"

[require]
php = "^8.2"
"laravel/framework" = "^11.0"
"psr/log" = "^3.0"

[autoload.psr-4]
"App\\" = ["src/"]

Native Monorepo Workspaces

Managing multi-package repositories in Composer typically requires tedious path repository configuration or third-party plugins. Phast supports Workspaces natively:

Multiple sub-packages maintained in a single Git repository.

Shared single top-level lock file ( phast.lock) and single vendor/ directory.

Dramatically simplifies dependency management for medium-to-large monorepos.

Built-in Supply Chain Security and Vulnerability Auditing

phast audit : reads the lock file directly and cross-references OSV and Packagist official vulnerability advisories.

Minimum Package Age policy : supports configuring a minimum package age filter to guard against malicious injection in the open-source ecosystem.

Deterministic Lock File

phast.lock

is generated using the PubGrub solving algorithm, precisely pinning versions, download URLs, Git commit hashes, checksums, and autoload rules, guaranteeing absolute consistency across environments and CI builds.

Benchmark Results

Real-World Project Test (Koel v9.15.0, 202 packages)

Tests run on Apple M3 Pro, PHP 8.4, Composer 2.8.10, high-speed network, median of 5 runs:

Cold start fresh install : Composer 67.32s vs Phast 7.00s → 9.6x faster

Install from lock : Composer 17.17s vs Phast 5.20s → 3.3x faster

Warm cache install : Composer 7.41s vs Phast 2.16s → 3.4x faster

Already-installed check (no-op) : Composer 3.12s vs Phast 0.53s → 5.9x faster

Laravel Skeleton Test (109 packages)

Cold Start: Phast 2.4x faster

From Lock File: Phast 3.0x faster

Warm Cache: Phast 5.7x faster

No-Op: Phast 6.7x faster (milliseconds)

Insight: the more dependencies and the larger the project, the more pronounced Phast's advantage in cold start and dependency resolution — compressing over a minute down to 7 seconds, nearly a 10x speedup.

Terminal Demo (Laravel app, 119 packages)

Full run: dependency resolution (0.31s), parallel download and install (1.70s), autoload map generation (0.13s) — total 2.26 seconds .

Why Is It So Fast?

Traditional Composer is a PHP CLI script; Phast is a pure Rust system binary. Three architectural innovations drive the speed:

1. Modern PubGrub-Based Solver

Phast adopts the PubGrub algorithm (same lineage as Python's uv and Dart's pub). It resolves dependency graphs with hundreds of packages, complex version conflicts, and constraints in tens to hundreds of milliseconds, with no PHP memory_limit constraints.

2. Fully Async Pipeline with Background Metadata Prefetching

Composer typically serializes network I/O and parsing. Phast concurrently probes and prefetches candidate package metadata while the solver runs, fully overlapping network I/O with CPU computation.

3. Multi-Threaded Parallel Downloads and Ultra-Fast Extraction

Built on Rust's async runtime (Tokio), Phast saturates CPU and bandwidth with multi-threaded concurrent downloads and archive extraction, eliminating the I/O blocking of single-threaded extraction of thousands of small files.

Installation

Linux/macOS one-liner :

curl -fsSL https://raw.githubusercontent.com/phast-sh/phast/main/install.sh | sh

Rust developers via Cargo :

cargo install --git https://github.com/phast-sh/phast phast

Command Comparison Table

Scaffold init : composer init → phast init Install all deps : composer install → phast install (auto-detects existing deps, parallel second-level install)

Add new dep : composer require foo/bar → phast add foo/bar (instant resolution and update)

Remove dep : composer remove foo/bar → phast remove foo/bar (instant cleanup and tree update)

Relock versions : composer update → phast update (parallel latest constraint computation)

One-click format migration : N/A → phast migrate (converts composer.json to phast.toml)

Vulnerability audit : composer audit → phast audit (built-in, no third-party plugin needed)

Phast + Mago: Full Rust Toolchain

If Phast reinvents Composer in Rust, Mago ( carthage.software) reshapes PHP's code-quality toolchain in Rust. Mirroring other languages' modernization:

Python: uv (package mgmt) + Ruff (format/lint)

Frontend: Bun (package mgmt/runtime) + Biome (code analysis)

PHP now: Phast + Mago

Mago Capabilities

Traditional PHP linting requires assembling PHP-CS-Fixer, PHPCS, PHPStan/Psalm, Deptrac — all PHP-based, slow startup, high memory on large projects. Mago bundles them into a single Rust native binary:

mago format : replaces PHP-CS-Fixer, PER-CS compliant, millisecond formatting of massive file sets.

mago lint : rule-level linting and smell detection, with one-click auto-fix ( mago lint --fix).

mago analyze : high-performance static type analysis, catches potential type errors without spinning up PHP runtime.

mago guard : architecture guard, enforces namespace and layer dependency rules (e.g., domain layer must not depend on infrastructure layer).

Ultra-Efficient CI Pipeline

Phast fetches and mounts all Composer dependencies in ~3 seconds; Mago completes full codebase lint, format, and static analysis in under 1 second. The entire PHP CI build and check process — originally 3-5 minutes — compresses into under 10 seconds . This is not just speed; it's a qualitative leap in compute cost and developer feedback loop.

Applicable Scenarios and Limitations

Despite impressive speed and compatibility, consider these before fully replacing production builds:

Complex PHP plugin ecosystem : plugins relying on Composer's internal PHP runtime hooks (e.g., cweagans/composer-patches or custom framework installers) cannot be executed natively by the external Rust CLI.

Lifecycle scripts (Scripts Hooks) : if composer.json defines post-install-cmd, pre-autoload-dump, etc., that depend deeply on Composer context, verify execution environment and argument consistency.

Enterprise private credential edge cases : standard tokens supported, but complex jump-host SSH keys or non-standard private registries should be validated on a dev machine first.

Summary

From PHPStan static analysis to FrankenPHP modern app server, and now the Rust-written Phast, the PHP ecosystem is undergoing a comprehensive upgrade to a new generation of high-performance infrastructure. Rewriting the package manager in Rust not only delivers 3-10x speedups but also frees developers from memory_limit woes.

Project website: https://phast.sh/ Official docs: https://docs.phast.sh/ GitHub repo: https://github.com/phast-sh/phast Mago toolchain: https://carthage.software/ (GitHub)

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Rustmonorepodependency managementPHPComposersecurity auditPubGrubPhast
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.