(Deprecated) Data objects for JavaScript and PHP. https://nymph.io
This repository has been archived on 2026-03-31. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
  • PHP 46.4%
  • Shell 41.2%
  • HTML 12.4%
Find a file
Hunter Perrin 7a864b6276 New commits.
2021-08-14 09:25:14 -07:00
assets Update README with better examples. More assets. 2018-05-04 14:23:48 -07:00
client@469437e463 New commits. 2021-08-14 09:25:14 -07:00
client-node@a9e99323a1 New commits. 2021-08-14 09:25:14 -07:00
examples@9420e627e5 New commits. 2021-08-14 09:25:14 -07:00
nymph.io@8f929e4f95 New commits. 2019-05-31 23:39:23 -07:00
pubsub@bbb0fb6031 New commits. 2021-08-14 09:25:14 -07:00
query-editor@85d9799edd New commits. 2021-08-14 09:25:14 -07:00
server@9db8414900 New commits. 2021-08-14 09:25:14 -07:00
tilmeld-client@7169e6f932 New commits. 2021-08-14 09:25:14 -07:00
tilmeld-components@03caf887f5 New commits. 2021-08-14 09:25:14 -07:00
tilmeld-server@1a823e7912 New commits. 2021-08-14 09:25:14 -07:00
tilmeld.org@88943a7da2 New commits. 2019-05-31 23:39:23 -07:00
.gitignore New commits. Freeze MySQL version number. 2019-04-12 17:53:34 -07:00
.gitmodules New commits. 2019-05-31 16:30:26 -07:00
autoload-dev.php Fixed run scripts to work with new JWT authentication. Removed Composer files, so all code runs from repos. 2018-04-29 12:22:56 -07:00
docker-compose.yml Add sys_nice capability to MySQL Docker. 2020-12-23 12:25:38 -08:00
Dockerfile-mysql Forward MySQL port for debugging. Unlock MySQL version. 2019-06-10 17:34:15 -07:00
Dockerfile-pubsub Docker setup improvement. 2018-05-18 11:40:28 -07:00
Dockerfile-web Docker setup improvement. 2018-05-18 11:40:28 -07:00
favicon.ico Icon and logo. 2018-05-04 08:43:35 -07:00
LICENSE Updated license file. 2017-06-16 19:04:54 -07:00
phpcs.xml Add top level PHP Code Sniffer config file. 2020-12-04 11:44:19 -08:00
README.md Add deprecation notice. 2021-08-14 09:25:07 -07:00
run.sh Run Tilmeld PubSub server in Docker. Fix composer install in run.sh. 2018-05-02 10:11:51 -07:00

Nymph

Build Status Demo App Uptime Last Commit license

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.

Nymph Server PubSub Server Tilmeld Server Browser Client Node.js Client Tilmeld Client App Examples

Dev Environment Installation

If you are interested in working on Nymph itself:

  1. 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 $USER
      
      Then log out and log back in.
  2. Get Docker Compose
    • From the repos on Ubuntu:
      sudo apt-get install docker-compose
      
  3. Clone the repo:
    git clone --recursive https://github.com/sciactive/nymph.git
    cd nymph
    
  4. Make sure the submodules are on master:
    git submodule foreach git checkout master
    
  5. Run the app:
    ./run.sh
    

Now you can see the example apps on your local machine:

API Docs

Check out the API Docs in the wiki.