sciactive/nymph
Composer 安装命令:
composer require sciactive/nymph
包简介
Powerful object data storage and querying for collaborative web apps.
关键字:
README 文档
README
Powerful object data storage and querying for collaborative web apps.
Nymph is an ORM with a powerful query language, modern client library, REST and Publish/Subscribe servers, and user/group management.
Deprecation Notice
The PHP implementation of Nymph/Tilmeld has been deprecated. It will no longer have any new features added. Instead, a new version of Nymph running on Node.js, written entirely in TypeScript will replace the PHP implementation. You can find it over at the Nymph.js repo.
Live Demos
Try opening the same one in two windows, and see one window update with changes from the other.
App Template
To start building an app with Nymph, you can use the Nymph App Template.
Nymph Entities
Nymph stores data in objects called Entities. Relationships between entities are done by saving one entity in another one's property.
// Creating entities is super easy. async function createBlogPost(title, body, archived) { // BlogPost extends Entity. const post = new BlogPost(); post.title = title; post.body = body; post.archived = archived; await post.$save(); // The post is now saved in the database. return post; } // Creating relationships is also easy. async function createBlogPostComment(post, body) { if (!(post instanceof BlogPost)) { throw new Error("post should be a BlogPost object!"); } const comment = new Comment(); comment.post = post; comment.body = body; await comment.$save(); return comment; } const post = await createBlogPost( "My First Post", "This is a great blog post!", false ); await createBlogPostComment(post, "It sure is! Wow!");
Nymph Query Language
Nymph uses an object based query language. It's similar to Polish notation, as 'operator' : ['operand', 'operand'].
// Object based queries are easy from the frontend. async function searchBlogPosts(userQuery, page = 0) { // The server will only return entities the user has access to. return await Nymph.getEntities( { class: BlogPost.class, limit: 10, offset: page * 10, }, { type: "&", // You can do things like pattern matching. like: ["title", "%" + userQuery + "%"], // Or strict comparison, etc. strict: ["archived", false], } ); } // Querying relationships is also easy. async function getBlogPostComments(post) { return await Nymph.getEntities( { class: BlogPostComment.class, }, { type: "&", ref: ["post", post], } ); } // Complicated queries are easy. async function getMyLatestCommentsForPosts(posts) { return await Nymph.getEntities( { // Get all comments... class: BlogPostComment.class, }, { type: "&", // ...made in the last day... gte: ["cdate", null, "-1 day"], // ...where the current user is the author... ref: ["user", await User.current()], }, { // ...and the comment is on any... type: "|", // ...of the given posts. ref: posts.map((post) => ["post", post]), } ); }
Nymph PubSub
Making collaborative apps is easy with the PubSub server.
function watchBlogPostComments(post, component) { const comments = component.state.comments || []; const subscription = Nymph.getEntities( { class: BlogPostComment.class, }, { type: "&", ref: ["post", post], } ).subscribe((update) => { // The PubSub server keeps us up to date on this query. PubSub.updateArray(comments, update); component.setState({ comments }); }); component.onDestroy(() => { subscription.unsubscribe(); }); }
User/Group Management
Tilmeld is a user management system for Nymph. Check it out at tilmeld.org.
Installation
If you want to build an app with Nymph, you can use the app template.
You can also install Nymph in an existing app by following the instructions in the server and client repos, or in the wiki for Nymph and PubSub.
Dev Environment Installation
If you are interested in working on Nymph itself:
- Get Docker
- You can run the Docker install script on Linux with:
curl -fsSL https://get.docker.com -o get-docker.sh sh get-docker.sh
- Or, from the repos on Ubuntu:
sudo apt-get install docker.io sudo usermod -a -G docker $USERThen log out and log back in.
- You can run the Docker install script on Linux with:
- Get Docker Compose
- From the repos on Ubuntu:
sudo apt-get install docker-compose
- From the repos on Ubuntu:
- Clone the repo:
git clone --recursive https://github.com/sciactive/nymph.git cd nymph - Make sure the submodules are on master:
git submodule foreach git checkout master
- Run the app:
./run.sh
Now you can see the example apps on your local machine:
- Todo App with Svelte
- Todo App with React
- Sudoku App
- Simple Clicker App
API Docs
Check out the API Docs in the wiki.
sciactive/nymph 适用场景与选型建议
sciactive/nymph 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 31 次下载、GitHub Stars 达 93, 最近一次更新时间为 2014 年 12 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「orm」 「mysql」 「postgresql」 「postgres」 「Object Relational Mapping」 「Object relational mapper」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sciactive/nymph 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sciactive/nymph 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sciactive/nymph 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
SilverStripe now has tentative support for PostgreSQL ('Postgres')
Dibi is Database Abstraction Library for PHP
Kinikit - PHP Application development framework MVC component
PHP Database ORM for Symfony1. Do NOT use for new projects: please move to a newest Symfony release and Doctrine2
Sql dumps containing databases for the linna apps.
Manage PostgreSQL schemas in Laravel applications
统计信息
- 总下载量: 31
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 93
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2014-12-20
