webgraphe/phlip
Composer 安装命令:
composer require webgraphe/phlip
包简介
Embeddable scripts for PHP
README 文档
README
Phlip (pronounced \ˈflip\) is an embeddable scripting language for PHP based on s-expressions.
How does it work?
A lexer tokenizes scripts and a parser assembles data structures. A script's behavior originates from data and code elements resolved from a controlled scope.
Integration is simpler with the Phlipy dialect.
Refer to Webgraphe\Phlip\Tests\Unit\ReadmeTest for the example below:
<?php use Webgraphe\Phlip\Phlipy; use Webgraphe\Phlip\Program; // Tokenize and parse code into a program $program = Program::parse('(lambda (x) (* x x))'); // Bootstrap a new scope with different level of Phlipy dialects $scope = Phlipy::basic()->getScope(); // Execute program within said scope $square = $program->execute($scope); // In this case, return value is an anonymous function - a lambda - calculating the square of a number // as per source code "(* x x)" var_dump($square(M_PI)); // (double)9.8696044010894
How to install
Add a dependency on your projects with Composer, using
composer require webgraphe/phlip.
You may also install it globally with composer global require webgraphe/phlip.
Why use Phlip
- Embeddable scripts mean data becomes code
- Easy to use
- Easy to learn
- Build your own dialect!
- Interoperable with PHP Classes
- Create test suites with
phlipunit(built on top of PHPUnit) - Ships with a literal REPL
(loop (print (eval (read))))
DISCLAIMER
Lisp is a often considered a Homoiconic (code as data) language.
Despite Phlip's usage of S-expressions and a somewhat successful attempt at reproducing McCarthy's eval, as the author
I do not consider Phlip be an homoiconic language as it relies on PHP's internal data structures such as array,
stdClass, native scalars, Closure and invokable classes for performance and convenience.
Phlip is embeddable in PHP and was built to allow transportation of code and data in a manner that can stay relatively secure, provided that functionalities interoperable with PHP stay in check.
For reference: Webgraphe\Phlip\Tests\System\LispTest::testMcCarthyEval()
webgraphe/phlip 适用场景与选型建议
webgraphe/phlip 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 02 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「lisp」 「dialect」 「embeddable」 「s-expression」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 webgraphe/phlip 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 webgraphe/phlip 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 webgraphe/phlip 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Symfony bundle for extending Doctrine ORM entities with custom attribute-driven metadata — cacheable mapping, embedded entity support, and autoconfigured drivers
Patches doctrine/orm to allow usage of nullable embeddables
Generate from model
Internetx API wrapper for laravel
Embeddable React-based marketplace UI for WordPress plugins. Consumed via Composer + Mozart; ships a webpack-built frontend and an MVC PHP backend.
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-02-09