What if you could build an entire programming language... just by asking?
Features โข Installation โข Usage โข Examples โข Roadmap
VHP isn't just another PHP implementation. It's a groundbreaking experiment in AI-assisted development: Can an entire production-grade language runtime be built purely through conversation with AI?
Every. Single. Line. Written through prompts to AI agents. Zero manual coding.
The result? A blazingly fast, memory-safe PHP 8.x bytecode VM written in pure Rust with zero dependencies โ and it actually works.
- ๐ฅ Blazingly Fast โ Stack-based bytecode VM compiled from Rust
- ๐ก๏ธ Rock-Solid Security โ Memory safety guaranteed by Rust's ownership model
- ๐ฏ Zero Dependencies โ Pure standard library, no external crates, no bloat
- โจ PHP 8.x Compatible โ Run your existing PHP code unchanged
- ๐ฎ Modern Features โ Arrow functions, match expressions, fibers, attributes, pipe operator
- ๐ Battle-Tested โ Comprehensive test suite
# Clone and build
git clone https://github.com/leocavalcante/vhp.git
cd vhp
cargo build --release
# Your first VHP program
./target/release/vhp -r 'echo "Hello from the future!";'
# Run any PHP file
./target/release/vhp script.php
# Run tests
make test
# Run performance benchmarks
make benchThat's it. You're now running PHP with Rust-level performance.
Run make bench to see performance characteristics:
Source Code โ Lexer โ Tokens โ Parser โ AST โ Compiler โ Bytecode โ VM โ Output
VHP uses a stack-based bytecode VM that compiles PHP to optimized bytecode. The compiler and VM are written in native Rust, providing:
- Zero-cost abstractions from Rust's ownership model
- No garbage collection overhead during execution
- Optimized built-in functions written in native Rust
- Efficient memory management with compile-time guarantees
The architecture follows a classic interpreter pipeline with compilation to bytecode for efficient execution.
VHP brings the cutting-edge features of PHP 8.x with the raw speed of Rust. Here's what you get:
<?php
// Arrow functions with automatic capture (PHP 7.4)
$numbers = [1, 2, 3, 4, 5];
$doubled = array_map(fn($x) => $x * 2, $numbers);
// First-class callables (PHP 8.1) - elegant function references
$formatter = strtoupper(...);
echo $formatter("hello"); // HELLO
// Method callables (PHP 8.1) - create closures from methods
class Calculator {
public function add($a, $b) {
return $a + $b;
}
public static function multiply($n) {
return $n * 2;
}
}
$calc = new Calculator();
$add = $calc->add(...);
echo $add(5, 3); // 8
$double = Calculator::multiply(...);
echo $double(7); // 14
// Pipe operator (PHP 8.5) - chain operations beautifully
$result = "hello world"
|> strtoupper(...)
|> str_replace("WORLD", "VHP", ...)
|> strlen(...);<?php
// Match expressions (PHP 8.0) - pattern matching done right
$status = match($code) {
200 => "Success",
404 => "Not Found",
500, 503 => "Server Error",
default => "Unknown"
};
// Enums (PHP 8.1) - type-safe choices
enum Status: string {
case Active = "active";
case Pending = "pending";
case Closed = "closed";
}
// Named arguments (PHP 8.0) - crystal clear function calls
createUser(
name: "Alice",
email: "alice@example.com",
verified: true
);<?php
// Fibers (PHP 8.1) - lightweight cooperative multitasking
$fiber = new Fiber(function(): void {
echo "Fiber started\n";
Fiber::suspend();
echo "Fiber resumed\n";
});
$fiber->start();
$fiber->resume(); // Non-blocking concurrent execution- โจ Anonymous Classes โ Create objects on-the-fly without declaring classes
- ๐๏ธ Constructor Property Promotion โ Less boilerplate, more productivity (PHP 8.0)
- ๐ Readonly Properties & Classes โ Immutability for safer code (PHP 8.1/8.2)
- ๐ญ Interfaces & Traits โ Flexible, composable design patterns
- ๐ก๏ธ Attributes โ Metadata that doesn't suck (PHP 8.0)
- ๐ซ Exception Handling โ try/catch/finally with throw expressions
- โ Runtime Type Validation โ Full parameter and return type checking (PHP 7.0+)
Here's where it gets wild: VHP is proof that AI can build production-grade systems.
Every function, every test, every feature โ built through natural language conversations with AI agents. No manual code writing. Just prompts, iteration, and AI doing the heavy lifting.
This is the experiment: Can you "vibe code" an entire programming language runtime into existence?
The answer: You're looking at it.
Fair question. Here's the thing: existing codebases.
There are millions of PHP applications in production right now. WordPress powers 43% of the web. Laravel runs countless startups. Drupal backs major enterprises. Custom PHP systems everywhere.
VHP gets you a new runtime for all of them โ without rewriting a single line of their code.
Vibe coding Rust gets you one new app. VHP gets you a platform for all PHP apps.
That's the difference between a tool and an ecosystem.
Core Language:
- โ
PHP tags (
<?php,?>,<?=) with mixed HTML/PHP - โ Variables, operators, and expressions
- โ Control flow (if/else, while, for, foreach, switch)
- โ Arrays (indexed, associative, nested, with trailing commas)
- โ User-defined and recursive functions
- โ Variadic functions and argument unpacking
Modern PHP Features:
- โ Arrow functions with automatic capture (PHP 7.4)
- โ First-class callables (PHP 8.1)
- โ Match expressions (PHP 8.0)
- โ Named arguments (PHP 8.0)
- โ Attributes with reflection (PHP 8.0)
- โ Enums - pure and backed (PHP 8.1)
- โ Pipe operator (PHP 8.5)
- โ Fibers for concurrency (PHP 8.1)
- โ Generators with yield/yield from (PHP 5.5/7.0) - parsing complete, full execution in progress
Object-Oriented Programming:
- โ Classes & Objects (properties, methods, constructors, $this)
- โ Static properties with late static binding (PHP 5.0/5.3)
- โ Static methods
- โ Inheritance
- โ Anonymous classes (PHP 7.0)
- โ Interfaces and Traits
- โ Abstract classes and methods
- โ Final classes and methods
- โ Constructor Property Promotion (PHP 8.0)
- โ Readonly properties (PHP 8.1)
- โ Readonly classes (PHP 8.2)
- โ Property hooks with get/set (PHP 8.4)
- โ Asymmetric visibility (PHP 8.4)
- โ #[\Override] attribute (PHP 8.3)
- โ
Object cloning with
cloneandclone with(PHP 8.4) - โ Magic methods (__toString, __invoke, __get/__set, __call)
Type System:
- โ Runtime type validation for parameters and return types (PHP 7.0+)
- โ Simple types (int, string, float, bool, array, object, callable, iterable, mixed)
- โ Nullable types (?int, ?string, PHP 7.1)
- โ Union types (int|string, PHP 8.0)
- โ Intersection types (Iterator&Countable, PHP 8.1)
- โ DNF types ((A&B)|C, PHP 8.2)
- โ Class type hints
- โ void and never return types
- โ declare(strict_types=1) for strict type checking (PHP 7.0)
PCRE Regex (PHP 4+):
- โ preg_match - Perform a regular expression match
- โ preg_match_all - Perform a global regular expression match
- โ preg_split - Split string by a regular expression
- โ preg_replace - Perform a regular expression search and replace
- โ preg_replace_callback - Perform a search and replace with a callback
- โ preg_grep - Return array entries that match a pattern
Date/Time Functions (PHP 4+):
- โ time - Current Unix timestamp
- โ mktime - Get Unix timestamp from date components
- โ strtotime - Parse date string to Unix timestamp
- โ gmdate - Format GMT/UTC date
- โ gmstrftime - Format date with locale
Namespaces:
- โ Namespace declarations (braced and unbraced syntax, PHP 5.3)
- โ Qualified names (Foo\Bar, \Foo\Bar)
- โ Use statements with aliases
- โ Group use declarations (PHP 7.0)
- โ Namespace resolution for classes and interfaces
Error Handling:
- โ Exception handling (try/catch/finally)
- โ Throw expressions (PHP 8.0)
- โ Multi-catch blocks
โ See complete feature documentation
We're just getting started. Check out roadmap to see what's coming:
- More built-in functions (date/time, advanced array functions)
- Full generator execution with send/throw/return methods
- Complete Fiber support
- Composer compatibility
- Performance optimizations
- And much more...
Want to be part of this experiment?
- ๐ Found a bug? Open an issue
- ๐ก Have an idea? Submit a feature request
- ๐ Improve docs? PRs welcome
- โ Add tests? We love comprehensive coverage
- โญ Show support? Star the repo
Every contribution helps prove that AI-assisted development can build real, production-grade software.
BSD 3-Clause License - see LICENSE for details.
Built with Rust ๐ฆ and AI ๐ค
An experiment in what's possible when humans and AI collaborate
Don't just read about it. Try it now.
