Skip to content

sinabio/meteor-ddp-php

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

meteor-ddp-php

A minimalist PHP library that implements DDP client, the realtime protocol for Meteor framework.

How to use

Suppose you have declared a remote function foo in your meteor server code :

Meteor.methods({
  foo : function (arg) {
    check(arg, Number);
    if (arg == 1) { return 42; }
    return "You suck";
  }
});

Then in your php client's code, you could just invoke foo by executing :

use zyzo\MeteorDDP\DDPClient;

$client = new DDPClient('localhost', 3000);

$client->connect();

$client->call("foo", array(1));
while(($a = $client->getResult("foo")) === null) {};

echo 'Result = ' . $a . PHP_EOL;

$client->stop();

===>

Result = 42

More use cases can be found in the examples folder.

How to install

This library is available via composer, the dependency manager for PHP. Please add this in your composer.json :

"require" : {
    "zyzo/meteor-ddp-php": "1.1.0"
}

and update composer to automatically retrieve the package :

php composer.phar update

Requirements : pthreads

pthreads is not part of php core library, and installing it in an non-supported php environment is hard work. Here's a pretty good tutorial on how to set up the whole thing from scratch : http://eddmann.com/posts/compiling-php-5-5-with-zts-and-pthreads-support/

Roadmap

None

Version

1.1.0

About

Minimalist PHP library for client-side DDP communication

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%