I'm using iron.io and its worker tasks for a background process. My code is fairly simple, just like:
<?php
require 'vendor/autoload.php';
$uri = "my_connection_string";
$client = new MongoClient($uri);
:
:
composer.json is like:
{
"require": {
"iron-io/iron_worker": "2.0.4",
"wp-cli/php-cli-tools": "~0.10.3"
}
}
Then I first install all dependencies,
docker run --rm -it -v "$PWD":/worker -w /worker iron/php:dev composer install
compress my code,
zip -r worker.zip .
upload it,
iron --env dev worker upload --name task-name -zip ./worker.zip iron/php:dev php ./worker.php
then this error output.
PHP Fatal error: Class 'MongoClient' not found in /mnt/task/worker.php on line xxx
I also tried MongoDB\Driver\Manager
, MongoDB\Driver\Client
, the same error occurs. When I tried running php -m
, it shows:
[PHP Modules]
Core
curl
date
ereg
fileinfo
filter
hash
json
libxml
mbstring
mysqlnd
pcre
readline
Reflection
session
SimpleXML
SPL
standard
tokenizer
xmlwriter
[Zend Modules]
It looks even MongoDB extension is not installed, while they say it's installed. http://dev.iron.io/worker/languages/php/
Am I missing something? How can I use MongoDB driver in PHP with iron worker?