xphp: a fast lane for the php language
xphp v0.2.0 brings real, runtime-enforced generics to php. this is the first post in a series about xphp, its tools, and AI engineering.

Around 20 years ago, I wrote my first line of php. Around 20 days ago, I started building a language on top of it. Now, xphp v0.2.0 is real.
What is xphp
In one sentence, xphp is a superset of php that adds real, runtime-enforced generics to the php language.
In a more inspirational mood, xphp is a fast lane for the php language, a bridge between what developers need today and what php may support in the future.
Every valid php file is already valid xphp; on top of php's type system you get generic classes, functions, and closures with bounds, defaults, and variance.
Experience was the driver. AI engineering was the multiplier
I'd had the knowledge, the skills, and the desire for years. The one thing I lacked was the opportunity (time is money). Then I realized that with AI engineering I could get it done with relatively little effort.
A long career in software development was fundamental to identify what, why and how to get it done. AI was a tool to execute the plan at non-human speed.
The experience I had creating guard rails as human developer is exactly what helped me to create guard rails for AI agents that can write much more code much faster. And you know, the faster you go, the more safety you need.
As the legend goes, Pablo Picasso sketched a drawing on a napkin in a few minutes and asked a woman for a large sum of money for it. When she protested that it only took him five minutes to draw, he replied, "My dear, It took me a lifetime to be able to draw this sketch."
What I built, and what I didn't
I went straight at the feature php developers have wanted for nearly twenty years, and that is notoriously hard to add: real generics.
Let me be precise and clear about this though: I did not invent the syntax.
The way you write generics in xphp — the turbofish ::<> at call sites, the bound notation, the declaration form — comes from the bound-erased generics RFC, and the credit for that surface belongs to its authors.
Adopting that syntax was a deliberate choice, not a shortcut: I wanted xphp to track where php itself is heading rather than fork off a private dialect — so the code you write today is meant to still be valid the day php ships generics natively.
What I designed is what sits underneath that syntax: the runtime semantics and the compiler. Those are the layers where the real decisions live, and they're the reason xphp exists as its own thing.
Generics: the start, not the finish line
Adding native generics to php — a long-awaited php feature — is genuinely hard work. The object model that's served the ecosystem for two decades doesn't bend easily.
Supporting generics proves that the compile-to-vanilla model handles non-trivial type-system additions. The remaining features are on the roadmap: type aliases, literal types, mapped and conditional types to name a few.
Monomorphization
That's a key difference between xphp and the RFC I mentioned above.
Through monomorphization the xphp compiler specializes every instantiation into its own concrete, fully-typed plain-php class — that's why the runtime safety is real without performance penalty.
It's the same syntax on the surface, but a deliberately different choice underneath.
That choice is the whole project in miniature — the syntax is borrowed; the semantics are the work.
class Collection<T> {
public function __construct(public T ...$items) {}
public function first(): ?T {
return $this->items[0] ?? null;
}
}
$users = new Collection::<User>(
new User('Alice'),
new User('Bob')
);
echo $users->first()?->name; // typed all the way through
The xphp code above compiles down to ordinary php that runs anywhere php already runs: zero runtime cost, no custom runtime, no fork.
Help wanted
Such a project can't be maintained by a single developer. v0.2.0 is simply me showing it's possible. Now xphp needs a group of people to keep it alive and evolving.
Start here: read the principles, pick a roadmap item, open an issue, challenge a design decision, or bring one of your own. The design is still soft enough to change, which means right now is the moment an opinion actually moves something.
By the way
Next post: a language is only as alive as its ecosystem
Latin is one of the most influential languages in history — precise, elegant, the ancestor of every Romance language and a good share of the vocabulary in the western world.
Despite that, it's nearly dead, because its ecosystem is also nearly dead: no community evolving it for new needs, no new work being built in it day to day. A language can't stay alive and grow without an ecosystem.
Programming languages are no different. Real generics are a genuine advance, but a language feature on its own is just Latin — admirable but not used.
What turns a programming language into something people actually reach for is everything around it: the editor that understands it, the framework that ships it, the community that builds with it.
The compiler is not going to be enough to support the language. Therefore in the same ~20 days I also created a few tools to support xphp:
I'm going to talk about them in the next post.

