Skip to content

phel-lang/phel-lang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4,245 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Phel logo

GitHub Build Status Scrutinizer Code Quality Scrutinizer Code Coverage Psalm Type-coverage Status Ask DeepWiki


Functional, Lisp-inspired language that compiles to PHP. Macros, persistent data structures, and expressive functional idioms for the PHP ecosystem.

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

Install and scaffold in under a minute:

composer require phel-lang/phel-lang
./vendor/bin/phel init

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 repl                     # interactive
./vendor/bin/phel build                    # compile to PHP for production

Inline snippets or shell pipelines via phel eval:

./vendor/bin/phel eval '(+ 1 2)'           # prints 3
echo '(println "hi")' | ./vendor/bin/phel eval -
./vendor/bin/phel eval - < script.phel

Single-file scratch layout: ./vendor/bin/phel init --minimal (no subdirectories).

Documentation

Start here

Guides

Reference

AI coding agents

  • resources/agents/ — Claude Code, Cursor, Codex, Gemini, Copilot, Aider
  • ./vendor/bin/phel agent-install [platform] [--all] — install skill file for your agent

Build PHAR

./build/phar.sh

Produces build/out/phel.phar.

Contribute

New here? Start with CONTRIBUTING.md — setup, workflow, "Where to Start". See AGENTS.md for architecture and review expectations.

About

A functional, Lisp-inspired language that compiles to PHP. Inspired by Clojure, Phel brings macros, persistent data structures, and expressive functional idioms to the PHP ecosystem.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Contributors