phel-lang/phel-lang
Composer 安装命令:
composer require phel-lang/phel-lang
包简介
Phel is a functional programming language that compiles to PHP
关键字:
README 文档
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 ./vendor/bin/phel config # inspect the merged config
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
4. Enable shell completion (optional)
./vendor/bin/phel completion dumps a tab-completion script for bash, zsh, or fish. It completes commands, their options, and dynamic values (function names for doc, project namespaces for run/test).
# bash — restart your shell afterwards ./vendor/bin/phel completion bash | sudo tee /etc/bash_completion.d/phel # zsh — write into a directory on your $fpath ./vendor/bin/phel completion zsh > "${fpath[1]}/_phel" # fish ./vendor/bin/phel completion fish > ~/.config/fish/completions/phel.fish
The zsh script starts with #compdef phel, so completion only triggers for a binary named phel on your $PATH. If you call ./vendor/bin/phel (or ./bin/phel in a dev checkout), symlink a global phel first, e.g. on macOS + Homebrew:
phel completion zsh > "$(brew --prefix)/share/zsh/site-functions/_phel" ln -sf "$PWD/bin/phel" "$(brew --prefix)/bin/phel" # global `phel` so #compdef matches rm -f ~/.zcompdump* # force compinit to rebuild # then open a new shell
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
- Getting Started: install, REPL, first script (5 min)
- CLI Reference & DX Guide: every command, the dev loop, compile vs eval vs run vs build
- phel-lang.org: full documentation, tutorials, exercises, blog
- Contributor docs: repository internals, agent tooling, project layout
- 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.
phel-lang/phel-lang 适用场景与选型建议
phel-lang/phel-lang 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.14k 次下载、GitHub Stars 达 516, 最近一次更新时间为 2021 年 01 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「language」 「functional」 「lisp」 「phel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 phel-lang/phel-lang 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 phel-lang/phel-lang 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 phel-lang/phel-lang 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Texy converts plain text in easy to read Texy syntax into structurally valid (X)HTML. It supports adding of images, links, nested lists, tables and has full support for CSS. Texy supports hyphenation of long words (which reflects language rules), clickable emails and URL (emails are obfuscated again
Easy to use i18n translation PHP class for multi-language websites
Connection 'Db' codeception module to 'Yii2' module database settings
Package for convenient work with Laravel's localization features
Store your language lines in the database, yaml or other sources
Functional library for php with proper currying
统计信息
- 总下载量: 6.14k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 516
- 点击次数: 42
- 依赖项目数: 20
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-01-22