L
L
LakeForest2021-05-07 00:09:02
PHP
LakeForest, 2021-05-07 00:09:02

Php Comet + Sokil\Mongo, why class '\MongoCollection' not found, although mongodb is installed on php?

I already tried to connect it - it worked. And with comet php page 500 response and in the logs

[ERR] /var/www/vendor/sokil/php-mongo/src/Collection.php:207 >> Class '\MongoCollection' not found

I tried to find this file - it says that it is on the path:
C:\Program Files\JetBrains\PhpStorm 2020.2.2\plugins\php\lib\php.jar!\stubs\mongo\mongo.php

How do I upload it to docker then?
My container:
FROM php:7.4-cli
RUN docker-php-ext-install sockets && apt-get update \
    && apt-get install -y libevent-dev libcurl4-openssl-dev pkg-config libssl-dev libonig-dev curl zip unzip \
    && pecl install event mongodb \
    && docker-php-ext-enable event mongodb \
    && docker-php-ext-install mbstring pcntl
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
COPY ./client_shop/backend /var/www
WORKDIR /var/www
RUN composer install
CMD php ./src/app.php stop
CMD php ./src/app.php start

composer.json
{
    "require": {
        "gotzmann/comet": "^1.2",
        "sokil/php-mongo": "^1.23"
    },
    "autoload": {
        "psr-4": { "app\\": "src/" }
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vamp, 2021-05-07
@LakeForest

You need to install the mongodb extension for PHP itself and the additional library alcaeus/mongo-php-adapter .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question