├── docgen ├── logo.png ├── gen.sh └── footer.tpl ├── testscenario ├── celeryconfig.py ├── README.md └── tasks.py ├── install_amqp.sh ├── amqplibconnectorssl.php ├── composer.json ├── unittest ├── CeleryPECLTest.php ├── CeleryAMQPLibTest.php └── unittest.php ├── test.php ├── README.md ├── amqppeclconnector.php ├── amqp.php ├── amqplibconnector.php └── celery.php /docgen/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DivideAndConquer/celery-php/master/docgen/logo.png -------------------------------------------------------------------------------- /testscenario/celeryconfig.py: -------------------------------------------------------------------------------- 1 | BROKER_URL = "amqp://gdr:test@localhost:5672/wutka" 2 | 3 | CELERY_RESULT_BACKEND = "amqp" 4 | 5 | CELERY_IMPORTS = ("tasks", ) 6 | 7 | CELERY_RESULT_SERIALIZER = "json" 8 | CELERY_TASK_RESULT_EXPIRES = None 9 | -------------------------------------------------------------------------------- /docgen/gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd /home/gdr/celery-php 4 | git pull 5 | 6 | phpdoc --title "PHP client for Celery task queue" -o HTML:Smarty:HandS -f /home/gdr/celery-php/celery.php -t /srv/celery-php-doc --sourcecode on 7 | cp docgen/logo.png /srv/celery-php-doc/media/ 8 | -------------------------------------------------------------------------------- /testscenario/README.md: -------------------------------------------------------------------------------- 1 | ## Setting up 2 | 3 | rabbitmqctl add_user gdr test 4 | rabbitmqctl add_vhost wutka 5 | rabbitmqctl set_permissions -p wutka gdr ".*" ".*" ".*" 6 | 7 | ## Running 8 | 9 | cd testscenario 10 | celery worker -l DEBUG -c 20 11 | # In another terminal 12 | phpunit Tests 13 | -------------------------------------------------------------------------------- /testscenario/tasks.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | from celery.task import task 3 | import time 4 | 5 | @task 6 | def add(x, y): 7 | print "Got add()" 8 | return x + y 9 | 10 | @task 11 | def add_delayed(x, y): 12 | print "Got add_delayed()" 13 | time.sleep(1) 14 | print "Woke up from add_delayed()" 15 | return x+y 16 | 17 | @task 18 | def fail(): 19 | print "Got fail()" 20 | return fffffff 21 | 22 | @task 23 | def delayed(): 24 | print "Got delayed()" 25 | time.sleep(2) 26 | print "Woke up from delayed()" 27 | return 'Woke up' 28 | -------------------------------------------------------------------------------- /install_amqp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Based on http://www.php.net/manual/en/amqp.installation.php 4 | # 5 | # Required packages (debian): 6 | sudo apt-get install git php5-dev make gcc autoconf pkg-config 7 | 8 | # Install librabbitmq-c 9 | git clone https://github.com/alanxz/rabbitmq-c.git 10 | cd rabbitmq-c 11 | git submodule init 12 | git submodule update 13 | autoreconf -i && ./configure && make && sudo make install 14 | 15 | # Install and compile PHP extension 16 | sudo pecl install amqp 17 | 18 | # Problem? 19 | # Make sure php.ini is loading amqp.so 20 | # Test with php -i | grep amqp 21 | -------------------------------------------------------------------------------- /amqplibconnectorssl.php: -------------------------------------------------------------------------------- 1 | =2.0.0" 19 | }, 20 | "autoload": { 21 | "classmap": ["celery.php"] 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /docgen/footer.tpl: -------------------------------------------------------------------------------- 1 |