phel-lang/phel-lang 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phel-lang/phel-lang

最新稳定版本:v0.37.0

Composer 安装命令:

composer require phel-lang/phel-lang

包简介

Phel is a functional programming language that compiles to PHP

README 文档

README

Phel logo

GitHub Build Status PHPStan level 6 Psalm level 1 Psalm Type-coverage Status

Packagist Version Packagist Downloads PHP Version Required License Ask DeepWiki

Functional, Lisp-inspired language compiling to 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

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

Setup and workflow: CONTRIBUTING.md. Architecture and review expectations: AGENTS.md.

统计信息

  • 总下载量: 4.14k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 502
  • 点击次数: 1
  • 依赖项目数: 16
  • 推荐数: 0

GitHub 信息

  • Stars: 502
  • Watchers: 9
  • Forks: 29
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固