phel-lang / phel-lang
Phel is a functional programming language that compiles to PHP
Fund package maintenance!
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|^8.0
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: ^11.0|^12.0|^13.0
- psalm/plugin-phpunit: ^0.19|^0.20
- rector/rector: ^2.3
- symfony/var-dumper: ^7.4|^8.0
- vimeo/psalm: ^6.16
- dev-main
- v0.42.0
- v0.41.0
- v0.40.0
- v0.39.0
- 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/2358-defenum-name-resolution
- dev-feat/2353-typed-constants
- dev-feat/2352-php-override
- dev-feat/2351-defenum-methods
- dev-feat/2350-tag-type-coverage
- dev-feat/2349-php-readonly-struct
- dev-feat/2348-php-callable
- dev-chore/release-0.42.0
- dev-fix/invoke-arity-error-hint
- dev-feat/defstruct-php-magic-methods
- dev-feat/gacela-1.15-production
- dev-chore/phpunit-13
- dev-chore/pre-release-deps
- dev-docs/2340-collapse-doc-linebreaks
- dev-feat/formatter-cljfmt-alignment
- dev-docs/core-math-predicate-examples
- dev-quality/repo-wide-10-10
- dev-fix/2089-narrow-do-simplifier
- dev-ci/fix-clojure-test-suite-workers
- 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-06-06 11:56:54 UTC
README
Lisp for PHP, macros, persistent data structures, REPL.
Get Started
composer require phel-lang/phel-lang
1. Open a REPL
./vendor/bin/phel repl
phel:1:> (->> [1 2 3 4 5] (filter odd?) (map #(* % %)) (reduce +)) 35 phel:2:> (defn greet [name] (str "Hello, " name "!")) | user/greet phel:3:> (greet "Phel") | "Hello, Phel!"
2. Scaffold a project
./vendor/bin/phel init # add `--minimal` for a single-file layout
Creates phel-config.php, src/phel/main.phel, tests/phel/main_test.phel. Then:
./vendor/bin/phel run src/phel/main.phel # run ./vendor/bin/phel test # tests ./vendor/bin/phel build # compile to PHP
3. 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
Prefer a project template?
web-skeletonorcli-skeleton: click Use this template for a one-click start.
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 |
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] # install skill file for one agent (claude, cursor, ...) ./vendor/bin/phel agent-install --auto # only agents detected in this project ./vendor/bin/phel agent-install --all # every supported platform
Repo-level AI tooling
Claude Code (.claude/) and Codex (.codex/, .agents/, AGENTS.md) configs generate from a single source tree under .agnostic-ai/ via agnostic-ai. Those directories are gitignored; run sync after cloning to materialize them. Add more targets (Gemini, Cursor, ...) by appending to targets: in agnostic-ai.yaml.
brew install Chemaclass/tap/agnostic-ai # or: go install github.com/chemaclass/agnostic-ai/cmd/agnostic-ai@latest agnostic-ai sync # regenerate per-tool configs
Edit specs under .agnostic-ai/{rules,agents,skills,hooks,scripts,overlays}/, then agnostic-ai sync again. A CI gate runs sync --check on every PR to block drift between the source and the (gitignored) emitted files.