Functional Lisp for PHP developers
Phel compiles a Lisp dialect to PHP. Macros, persistent data structures, and REPL-driven development on any PHP host.
Phel by example
(->> (range 1 11)
(filter odd?)
(map #(* % %))
(reduce +))
# => 165Threading pipelines
- Reads top to bottom, no nested calls
- Each step is one pure function
- Immutable data, predictable output
- Same
->>macro PHP devs miss from RxJS or pipe operators
(php/strlen "hello, phel")
# => 11
(php/array_sum
(to-php-array [1 2 3 4]))
# => 10
(php/-> (php/new \DateTime)
(format "Y"))
# => "2026"Direct PHP interop
php/prefix calls any built-in functionphp/->is the PHP method-call operatorphp/newconstructs PHP classes- Composer packages work without wrappers
(defmacro unless [pred & body]
`(if (not ~pred) (do ~@body)))
(def x 5)
(unless (zero? x)
(println "x is non-zero")
(/ 10 x))Code as data
defmacroextends the language at compile time- Backtick +
~,~@build syntax trees - Zero runtime cost, expands before compilation
- Impossible in a library, only in a Lisp
(ns my.sum-test
(:require phel.test
:refer [deftest is]))
(deftest sum-test
(is (= 6 (+ 1 2 3)))
(is (= [1 4 9]
(map #(* % %)
[1 2 3]))))Tests are functions
deftest+is, no extra framework- Plain Phel, REPL-friendly
- Run with
vendor/bin/phel test - Same namespace and dependency model as production code
Why Phel?
vs vanilla PHP
More expression. Same runtime.
Macros, persistent collections, and a REPL, without leaving the PHP ecosystem. Composer, FPM, shared hosting all work.
vs Clojure on JVM
Lisp without the JVM.
Same Lisp ideas as Clojure, deployed like a PHP app. No JVM warmup, no AOT pipeline, no extra hosting target.
vs PHP FP libraries
Language, not library.
Real homoiconic syntax, real macros, real tail-call elimination. A library can't extend PHP's grammar. Phel doesn't need to.
Try it in 30 seconds
Try without installing anything. Drops you into a REPL.
docker run -it --rm phellang/repl Add to an existing PHP project.
composer require phel-lang/phel-lang
vendor/bin/phel repl Single-file binary, no Composer required.
curl -L https://phel-lang.org/phar -o phel.phar
php phel.phar repl Full walkthrough in the installation guide.
Common questions
Is Phel production-ready?
Not yet. Phel is pre-1.0. The core language and tooling are usable for personal projects, prototypes, and internal tools, but breaking changes can land between minor releases. Track release notes if you depend on it.
Can I call PHP libraries from Phel?
Yes. Phel compiles to PHP, so any Composer package, function, or class is directly callable via the
php/ prefix. See the interop guide.How is Phel different from Clojure?
Phel borrows ideas from Lisp and Clojure (immutable data, macros, threading) but targets the PHP runtime, not the JVM. No agents, no STM, no atoms. Phel maps to PHP's execution model. See the design rationale.
What PHP version do I need?
The current release targets PHP 8.4 or later. Earlier Phel versions support older PHP releases if you need them.