phel-lang / phel-lang
Phel is a functional programming language that compiles to PHP
Fund package maintenance!
v0.38.0
2026-05-16 18:05 UTC
Requires
- php: >=8.4
- amphp/amp: ^3.1
- gacela-project/gacela: ^1.14
- symfony/console: ^6.0|^7.0|^8.0
- symfony/routing: ^7.3
Requires (Dev)
- ext-readline: *
- ergebnis/composer-normalize: ^2.50
- friendsofphp/php-cs-fixer: ^3.94
- phpbench/phpbench: ^1.6
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.5
- psalm/plugin-phpunit: ^0.19
- rector/rector: ^2.3
- symfony/var-dumper: ^7.4
- vimeo/psalm: ^6.16
- dev-main
- v0.38.0
- v0.37.0
- v0.36.0
- v0.35.0
- v0.34.1
- v0.34.0
- v0.33.0
- v0.32.0
- v0.31.0
- v0.30.0
- v0.29.0
- v0.28.0
- v0.27.0
- v0.26.0
- v0.25.0
- v0.24.0
- v0.23.1
- v0.23.0
- v0.22.2
- v0.22.1
- v0.22.0
- v0.21.0
- v0.20.0
- v0.19.1
- v0.19.0
- v0.18.1
- v0.18.0
- v0.17.0
- v0.16.1
- v0.16.0
- v0.15.3
- v0.15.2
- v0.15.1
- v0.15.0
- v0.14.1
- v0.14.0
- v0.13.0
- v0.12.0
- v0.11.0
- v0.10.1
- v0.10.0
- v0.9.0
- v0.8.0
- v0.7.0
- v0.6.0
- v0.5.0
- v0.4.0
- v0.3.3
- v0.3.2
- v0.3.1
- v0.3.0
- v0.2.0
- v0.1.0
- dev-fix/1998-buildcommand-load-resolution
- dev-ref/exception-info-rename
- dev-ref/2000-rename-phelfuture-to-future
- dev-ref/2000-rename-rational-to-ratio
- dev-ref/2000-rename-biginteger-to-bigint
- dev-ref/2000-rename-uuid-to-UUID
- dev-ref/2000-rename-variable-to-atom
- dev-feat/auto-refer-lang-types
- dev-fix/lazy-seq-semantics
- dev-fix/test-flags-polish
- dev-feat/lazy-seq-predicate
- dev-perf/file-evaluator-fingerprint-cache
- dev-feat/1693-require-vector-syntax
- dev-fix/1692-repl-namespace-preservation
- dev-fix/issue-1692
This package is auto-updated.
Last update: 2026-05-17 17:44:31 UTC
README
Lisp for PHP — macros, persistent data structures, REPL.
Example
(ns my.example) (defn greet [name] (str "Hello, " name "!")) (println (greet "Phel")) ;; => Hello, Phel!
More examples →
|
Data pipeline (def users [{:name "Ada" :age 36} {:name "Bob" :age 17} {:name "Cam" :age 41}]) (->> users (filter #(>= (:age %) 18)) (map :name) sort) ;; => ["Ada" "Cam"] |
HTTP response (ns app (:require phel.http :as h)) (def req (h/request-from-globals)) (h/emit-response (h/response-from-map {:status 200 :headers {"Content-Type" "text/plain"} :body (str "Hello " (:uri req))})) |
|
Macros (defmacro unless [pred & body] `(if (not ~pred) (do ~@body))) (unless (zero? 1) (println "not zero")) ;; => not zero (unless false (println "ok")) ;; => ok |
PHP interop (ns app) (def now (php/new \DateTime)) (.format now "Y-m-d") ;; => "2026-04-20" (def epoch (php/new \DateTime "1970-01-01")) (.-days (.diff now epoch)) ;; => 20564 |
Getting Started
composer require phel-lang/phel-lang
./vendor/bin/phel init # add `--minimal` for a single-file layout
Scaffolds phel-config.php, src/phel/main.phel, tests/phel/main_test.phel.
./vendor/bin/phel run src/phel/main.phel # run ./vendor/bin/phel test # tests ./vendor/bin/phel repl # REPL ./vendor/bin/phel build # compile to PHP
Eval inline or via stdin:
./vendor/bin/phel eval '(+ 1 2)' # prints 3 echo '(println "hi")' | ./vendor/bin/phel eval - ./vendor/bin/phel eval - < script.phel
Documentation
- Quick Start: install, REPL, first script (5 min)
- Documentation Index: every guide, grouped by purpose
- phel-lang.org: tutorials, exercises, blog
- Packagist
- CONTRIBUTING.md: setup and workflow
- AGENTS.md: architecture and review expectations
AI Coding Agents
Skill files for Claude Code, Cursor, Codex, Gemini, Copilot, Aider: resources/agents/
./vendor/bin/phel agent-install [platform] [--all] # install skill file for your agent