• This repository has been archived on 30/Nov/2021
  • Stars
    star
    422
  • Rank 102,415 (Top 3 %)
  • Language
    PHP
  • License
    Other
  • Created about 13 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PHP client for Celery

Archived

I have no more commercial or personal use for this project. It doesn't seem to be used by any Free Software projects and I'm definitely not spending my spare time on something used internally by some random companies I never met. Check out the forks, maybe you'll find something that works for you there.

Thanks to all the contributors!

PHP client capable of executing Celery tasks and reading asynchronous results.

Uses AMQP extension from PECL, the PHP AMQP implementation or Redis and the following settings in Celery:

result_serializer = 'json'
result_expires = None
task_track_started = False

The required PECL-AMQP version is at least 1.0. Last version tested is 1.4.

Last PHP-amqplib version tested is 2.5.1.

Last predis version tested is 1.0.1.

Requires Celery 4.0+.

API documentation is dead, help wanted

POSTING TASKS

$c = new \Celery\Celery('localhost', 'myuser', 'mypass', 'myvhost');
$result = $c->PostTask('tasks.add', array(2,2));

// The results are serializable so you can do the following:
$_SESSION['celery_result'] = $result;
// and use this variable in an AJAX call or whatever

tip: if using RabbitMQ guest user, set "/" vhost

READING ASYNC RESULTS

while (!$result->isReady())    {
    sleep(1);
    echo '...';
}

if ($result->isSuccess()) {
    echo $result->getResult();
} else {
    echo "ERROR";
    echo $result->getTraceback();
}

GET ASYNC RESULT MESSAGE

$c = new \Celery\Celery('localhost', 'myuser', 'mypass', 'myvhost');
$message = $c->getAsyncResultMessage('tasks.add', 'taskId');

PYTHON-LIKE API

An API compatible to AsyncResult in Python is available too.

$c = new \Celery\Celery('localhost', 'myuser', 'mypass', 'myvhost');
$result = $c->PostTask('tasks.add', array(2,2));

$result->get();
if ($result->successful()) {
    echo $result->result;
}

ABOUT

Based on this blog post and reading Celery sources. Thanks to Skrat, author of Celerb for a tip about response encoding. Created for the needs of my consulting work at Massive Scale.

License is 2-clause BSD.

DEVELOPMENT

Development process and goals.

CONNECTING VIA SSL

Connecting to a RabbitMQ server that requires SSL is currently only possible via PHP-amqplib to do so you'll need to create a celery object with ssl options:

$ssl_options = [
    'cafile' => 'PATH_TO_CA_CERT_FILE',
    'verify_peer' => true,
    'passphrase' => 'LOCAL_CERT_PASSPHRASE',
    'local_cert' => 'PATH_TO_COMBINED_CLIENT_CERT_KEY',
    'CN_match' => 'CERT_COMMON_NAME'
];

$c = new \Celery\Celery($host, $user, $password, $vhost, 'celery', 'celery', 5671, false, 0, $ssl_options);

CONNECTING TO REDIS

Refer to files in testscenario/ for examples of celeryconfig.py.

$c = new \Celery\Celery(
    'localhost', /* Server */
    '', /* Login */
    'test', /* Password */
    'wutka', /* vhost */
    'celery', /* exchange */
    'celery', /* binding */
    6379, /* port */
    'redis' /* connector */
);

More Repositories

1

tuntox

Tunnel TCP connections over the Tox protocol
C
343
star
2

paranoia

Paranoia add-on for Thunderbird. See who is reading your emails.
JavaScript
34
star
3

mylocation

Share your location on Android - with Email, SMS, Conversations, Tox, Whatsapp etc
Java
29
star
4

androidwisprclient

A client for automatic authentication in FON network (fork)
Java
13
star
5

mplayer-android

*THIS PROJECT IS ABANDONED* Trying to port mplayer to ndk
C
9
star
6

nordvpn

NordVPN server list parser
HTML
8
star
7

vzdup

Yoonique's vzdup (may contain my modifications)
Perl
6
star
8

xmpp-youtube-dl-bot

Download youtube videos and MP3s over XMPP
Python
5
star
9

php-phone-sanitizer

International phone number sanitizer
PHP
5
star
10

archivebox-index-generator

View your ArchiveBox index without the bloat, just a web browser
Python
5
star
11

check_permissions

A small script to check permissions and display mismatches
Python
4
star
12

Share-to-Talk

Android app for easy sharing to google talk (gtalk) contacts
Java
4
star
13

opentopomap-cache-docker

A fork of https://github.com/cyclestreets/tilecache for caching OpenTopoMap tiles
PHP
4
star
14

docker-elk-netflow

Elasticsearch/Logstash/Kibana setup with Netflow configured
Shell
4
star
15

invent

Invent with Python PL
TeX
2
star
16

docker-syslogserver

This container creates a Syslog server with Rsyslogd, logs are accessible via PimpMyLogs interface
PHP
2
star
17

fdroid-repo

My personal F-Droid repo at https://fdroid.gdr.name/
Shell
2
star
18

opencv

Play Pong just with your bare hands! (and a camera)
Python
2
star
19

ttrss-af_nofacebook

Replaces Facebook l.php redirect links with direct ones
PHP
2
star
20

lineageos_device_chooser

Choose your perfect LineageOS device by filtering data from the LOS Wiki and sorting by popularity
Python
2
star
21

gcal-plasmoid

KDE plasmoid with Google Calendar agenda
Python
2
star
22

refunkify

Collect all photos from a trip into a single directory
Python
1
star
23

PrivateBin-webextension

A proof-of-concept webextension for verifying JS integrity
Shell
1
star
24

django-twocheckout

Half-baked 2checkout.com INS support for Django
Python
1
star
25

custom-attachment-names-wp-mail

wp_mail()-like function which can do custom attachment names
PHP
1
star
26

postfix-policy-whois

Block spam based on whois queries
Python
1
star
27

kde_unite

KDE service menu for integration with Opera Unite
Python
1
star
28

webdav1000

derkades/webdav but the User ID is 1000 - a webdav server in Docker
Dockerfile
1
star