Closed dejwsz closed 4 months ago
What is interesting similar setup works well with Laravel 8 and Mongo driver. But Laravel 9 is not working anymore.
What is interesting DB seed work OK (executed by 'php artisan db:seed'):
INFO Seeding database. Database\Seeders\UsersTableSeeder ........................................................................................................ RUNNING Database\Seeders\UsersTableSeeder ................................................................................................. 248.23 ms DONE
But later during Laravel 9 bootstrap such error occurs ('php artisan serve --port=$PORT --host=0.0.0.0'):
WARN PHP Fatal error: Uncaught InvalidArgumentException: Driver [mongodb. WARN Stack trace: WARN #0 vendor/laravel/framework/src/Illuminate/Support/Manager.php(80): Illuminate\Support\Manager->createDriver(). WARN #1 vendor/laravel/framework/src/Illuminate/Session/SessionServiceProvider.php(52): Illuminate\Support\Manager->driver(). WARN #2 vendor/laravel/framework/src/Illuminate/Container/Container.php(885): Illuminate\Session\SessionServiceProvider->Illuminate\Session\{closure}(). WARN #3 vendor/laravel/framework/src/Illuminate/Container/Container.php(770): Illuminate\Container\Container->build(). WARN #4 vendor/laravel/framework/src/Illuminate/Foundation/Application.php(856): Illuminate\Container\Container->resolve(). WARN #5 vendor/laravel/framework/src/Illuminate/Container/Container.php(706): Illuminate\Foundation\Application->resolve(). WARN #6 vendor/laravel/framework/src/Illuminate/Foundation/Application.php(841): Illuminate\Container\Container->make(). WARN #7 vendor/laravel/framework/src/Illuminate/Container/Container.php(1431): Illuminate\Foundation\Application->make(). WARN #8 vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php(120): Illuminate\Container\Container->offsetGet(). WARN #9 vendor/laravel/framework/src/Illuminate/Container/Container.php(885): Illuminate\Routing\RoutingServiceProvider->Illuminate\Routing\{closure}(). WARN #10 vendor/laravel/framework/src/Illuminate/Container/Container.php(770): Illuminate\Container\Container->build(). WARN #11 vendor/laravel/framework/src/Illuminate/Foundation/Application.php(856): Illuminate\Container\Container->resolve(). WARN #12 vendor/laravel/framework/src/Illuminate/Container/Container.php(706): Illuminate\Foundation\Application->resolve(). WARN #13 vendor/laravel/framework/src/Illuminate/Foundation/Application.php(841): Illuminate\Container\Container->make(). WARN #14 vendor/laravel/framework/src/Illuminate/Container/Container.php(1431): Illuminate\Foundation\Application->make(). WARN #15 vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php(174): Illuminate\Container\Container->offsetGet(). WARN #16 vendor/laravel/framework/src/Illuminate/Container/Container.php(885): Illuminate\Routing\RoutingServiceProvider->Illuminate\Routing\{closure}(). WARN #17 vendor/laravel/framework/src/Illuminate/Container/Container.php(770): Illuminate\Container\Container->build(). WARN #18 vendor/laravel/framework/src/Illuminate/Foundation/Application.php(856): Illuminate\Container\Container->resolve(). WARN #19 vendor/laravel/framework/src/Illuminate/Container/Container.php(706): Illuminate\Foundation\Application->resolve(). WARN #20 vendor/laravel/framework/src/Illuminate/Foundation/Application.php(841): Illuminate\Container\Container->make(). WARN #21 vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(120): Illuminate\Foundation\Application->make(). WARN #22 vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(805): app(). WARN #23 vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(626): response(). WARN #24 vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(554): Illuminate\Foundation\Exceptions\Handler->renderHttpException(). WARN #25 vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(460): Illuminate\Foundation\Exceptions\Handler->prepareResponse(). WARN #26 vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(377): Illuminate\Foundation\Exceptions\Handler->renderExceptionResponse(). WARN #27 app/Exceptions/Handler.php(59): Illuminate\Foundation\Exceptions\Handler->render(). WARN #28 vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(233): App\Exceptions\Handler->render(). WARN #29 vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(210): Illuminate\Foundation\Bootstrap\HandleExceptions->renderHttpResponse(). WARN #30 vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(270): Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(). WARN #31 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->Illuminate\Foundation\Bootstrap\{closure}(). WARN #32 {main}. WARN thrown in vendor/laravel/framework/src/Illuminate/Support/Manager.php on line 109. WARN PHP Fatal error: Uncaught InvalidArgumentException: Driver [mongodb. WARN Stack trace: WARN #0 vendor/laravel/framework/src/Illuminate/Support/Manager.php(80): Illuminate\Support\Manager->createDriver().
FROM php:8.1-fpm-bullseye
ARG PORT=8000 ENV PORT=${PORT}
ARG VERSION="latest" ARG CREATED="now" ARG REVISION="latest" LABEL org.opencontainers.image.version=$VERSION LABEL org.opencontainers.image.revision=$REVISION LABEL org.opencontainers.image.created=$CREATED
RUN apt-get update -y && \ apt-get install -y autoconf pkg-config libssl-dev libzip-dev zlib1g-dev zip unzip && \ pecl install mongodb && \ docker-php-ext-enable mongodb && \ pecl clear-cache && \ apt-get clean && \ rm -rf /var/lib/apt/lists/*
COPY --from=composer:2.5.8 /usr/bin/composer /usr/bin/composer
WORKDIR /var/www
RUN mkdir -p /var/www/vendor && \ mkdir -p /var/www/storage/logs/ && \ chown -R www-data:www-data /var/www/
USER www-data:www-data
COPY --chown=www-data:www-data ./backend ./
RUN composer install --no-progress --ignore-platform-reqs
USER root
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" COPY docker/backend/opcache.ini $PHP_INI_DIR/conf.d/opcache.ini
ENV PATH="/var/www/vendor/bin:$PATH"
EXPOSE $PORT
ENTRYPOINT ["/var/www/docker/entrypoint.sh"]
Composer.json file:
{ "name": "laravel/laravel", "type": "project", "version": "0.1.0", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "require": { "php": "^8.1", "aws/aws-sdk-php": "^3.225", "fruitcake/laravel-cors": "^2.0", "guzzlehttp/guzzle": "^7.0.1", "jenssegers/mongodb": "^3.9", "laravel/framework": "^9.0", "laravel/tinker": "^2.5", "nextapps/laravel-swagger-ui": "^0.6.0", "opcodesio/log-viewer": "^1.5", "robsontenorio/laravel-keycloak-guard": "^1.4", "vyuldashev/laravel-openapi": "^1.8" }, "require-dev": { "spatie/laravel-ignition": "^1.0", "fakerphp/faker": "^1.9.1", "laravel/sail": "^1.0.1", "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^6.1", "nunomaduro/larastan": "^1.0", "phpunit/phpunit": "^9.5.10" }, "autoload": { "psr-4": { "App\": "app/", "Database\Factories\": "database/factories/", "Database\Seeders\": "database/seeders/" } }, "autoload-dev": { "psr-4": { "Tests\": "tests/" } }, "scripts": { "post-autoload-dump": [ "Illuminate\Foundation\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi" ], "post-update-cmd": [ "@php artisan vendor:publish --tag=laravel-assets --ansi --force" ], "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ "@php artisan key:generate --ansi" ] }, "extra": { "laravel": { "dont-discover": [ ] } }, "config": { "optimize-autoloader": true, "preferred-install": "dist", "sort-packages": true }, "minimum-stability": "dev", "prefer-stable": true }
### Expected behaviour Driver is loaded. ### Actual behaviour Some debug info:
composer show mongodb/mongodb:
name : mongodb/mongodb descrip. : MongoDB driver library keywords : database, driver, mongodb, persistence versions : * 1.15.0 type : library license : Apache License 2.0 (Apache-2.0) (OSI approved) https://spdx.org/licenses/Apache-2.0.html#licenseText homepage : https://jira.mongodb.org/browse/PHPLIB source : [git] https://github.com/mongodb/mongo-php-library.git 3a681a3b2f2c0ebac227a3b86bb9057d0e6eb8f8 dist : [zip] https://api.github.com/repos/mongodb/mongo-php-library/zipball/3a681a3b2f2c0ebac227a3b86bb9057d0e6eb8f8 3a681a3b2f2c0ebac227a3b86bb9057d0e6eb8f8 path : /var/www/vendor/mongodb/mongodb names : mongodb/mongodb
support issues : https://github.com/mongodb/mongo-php-library/issues source : https://github.com/mongodb/mongo-php-library/tree/1.15.0
autoload files psr-4 MongoDB\ => src/
requires ext-hash ext-json ext-mongodb ^1.15.0 jean85/pretty-package-versions ^1.2 || ^2.0.1 php ^7.2 || ^8.0 symfony/polyfill-php80 ^1.19
requires (dev) doctrine/coding-standard ^9.0 squizlabs/php_codesniffer ^3.6 symfony/phpunit-bridge ^5.2 vimeo/psalm ^4.28
php --ri mongodb:
mongodb
MongoDB support => enabled MongoDB extension version => 1.15.3 MongoDB extension stability => stable libbson bundled version => 1.23.4 libmongoc bundled version => 1.23.4 libmongoc SSL => enabled libmongoc SSL library => OpenSSL libmongoc crypto => enabled libmongoc crypto library => libcrypto libmongoc crypto system profile => disabled libmongoc SASL => disabled libmongoc ICU => disabled libmongoc compression => enabled libmongoc compression snappy => disabled libmongoc compression zlib => enabled libmongoc compression zstd => disabled libmongocrypt bundled version => 1.5.2 libmongocrypt crypto => enabled libmongocrypt crypto library => libcrypto crypt_shared library version => unknown
Directive => Local Value => Master Value mongodb.debug => no value => no value
composer show jenssegers/mongodb:
name : jenssegers/mongodb descrip. : A MongoDB based Eloquent model and Query builder for Laravel (Moloquent) keywords : database, eloquent, laravel, model, moloquent, mongo, mongodb versions : * v3.9.5 type : library license : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText homepage : https://github.com/jenssegers/laravel-mongodb source : [git] https://github.com/jenssegers/laravel-mongodb.git 6ce35ace85a5946f943d7f493f93aebb9a6d129d dist : [zip] https://api.github.com/repos/jenssegers/laravel-mongodb/zipball/6ce35ace85a5946f943d7f493f93aebb9a6d129d 6ce35ace85a5946f943d7f493f93aebb9a6d129d path : /var/www/vendor/jenssegers/mongodb names : jenssegers/mongodb
support issues : https://github.com/jenssegers/laravel-mongodb/issues source : https://github.com/jenssegers/laravel-mongodb/tree/v3.9.5
autoload psr-4 Jenssegers\Mongodb\ => src/
requires illuminate/container ^9.0 illuminate/database ^9.0 illuminate/events ^9.0 illuminate/support ^9.0 mongodb/mongodb ^1.11
requires (dev) doctrine/dbal ^2.13.3|^3.1.4 mockery/mockery ^1.3.1 orchestra/testbench ^7.0 phpunit/phpunit ^9.5.8
suggests jenssegers/mongodb-sentry Add Sentry support to Laravel-MongoDB jenssegers/mongodb-session Add MongoDB session support to Laravel-MongoDB
just install mongodb driver by adding this command in Dockerfile :
RUN pecl install mongodb
then add extension=mongodb.so in php.ini
extension=mongodb.so
Description:
What is interesting similar setup works well with Laravel 8 and Mongo driver. But Laravel 9 is not working anymore.
What is interesting DB seed work OK (executed by 'php artisan db:seed'):
But later during Laravel 9 bootstrap such error occurs ('php artisan serve --port=$PORT --host=0.0.0.0'):
Steps to reproduce
ARG PORT=8000 ENV PORT=${PORT}
ARG VERSION="latest" ARG CREATED="now" ARG REVISION="latest" LABEL org.opencontainers.image.version=$VERSION LABEL org.opencontainers.image.revision=$REVISION LABEL org.opencontainers.image.created=$CREATED
RUN apt-get update -y && \ apt-get install -y autoconf pkg-config libssl-dev libzip-dev zlib1g-dev zip unzip && \ pecl install mongodb && \ docker-php-ext-enable mongodb && \ pecl clear-cache && \ apt-get clean && \ rm -rf /var/lib/apt/lists/*
COPY --from=composer:2.5.8 /usr/bin/composer /usr/bin/composer
WORKDIR /var/www
RUN mkdir -p /var/www/vendor && \ mkdir -p /var/www/storage/logs/ && \ chown -R www-data:www-data /var/www/
USER www-data:www-data
COPY --chown=www-data:www-data ./backend ./
RUN composer install --no-progress --ignore-platform-reqs
USER root
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" COPY docker/backend/opcache.ini $PHP_INI_DIR/conf.d/opcache.ini
USER www-data:www-data
ENV PATH="/var/www/vendor/bin:$PATH"
EXPOSE $PORT
ENTRYPOINT ["/var/www/docker/entrypoint.sh"]
{ "name": "laravel/laravel", "type": "project", "version": "0.1.0", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "require": { "php": "^8.1", "aws/aws-sdk-php": "^3.225", "fruitcake/laravel-cors": "^2.0", "guzzlehttp/guzzle": "^7.0.1", "jenssegers/mongodb": "^3.9", "laravel/framework": "^9.0", "laravel/tinker": "^2.5", "nextapps/laravel-swagger-ui": "^0.6.0", "opcodesio/log-viewer": "^1.5", "robsontenorio/laravel-keycloak-guard": "^1.4", "vyuldashev/laravel-openapi": "^1.8" }, "require-dev": { "spatie/laravel-ignition": "^1.0", "fakerphp/faker": "^1.9.1", "laravel/sail": "^1.0.1", "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^6.1", "nunomaduro/larastan": "^1.0", "phpunit/phpunit": "^9.5.10" }, "autoload": { "psr-4": { "App\": "app/", "Database\Factories\": "database/factories/", "Database\Seeders\": "database/seeders/" } }, "autoload-dev": { "psr-4": { "Tests\": "tests/" } }, "scripts": { "post-autoload-dump": [ "Illuminate\Foundation\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi" ], "post-update-cmd": [ "@php artisan vendor:publish --tag=laravel-assets --ansi --force" ], "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ "@php artisan key:generate --ansi" ] }, "extra": { "laravel": { "dont-discover": [ ] } }, "config": { "optimize-autoloader": true, "preferred-install": "dist", "sort-packages": true }, "minimum-stability": "dev", "prefer-stable": true }
composer show mongodb/mongodb:
name : mongodb/mongodb descrip. : MongoDB driver library keywords : database, driver, mongodb, persistence versions : * 1.15.0 type : library license : Apache License 2.0 (Apache-2.0) (OSI approved) https://spdx.org/licenses/Apache-2.0.html#licenseText homepage : https://jira.mongodb.org/browse/PHPLIB source : [git] https://github.com/mongodb/mongo-php-library.git 3a681a3b2f2c0ebac227a3b86bb9057d0e6eb8f8 dist : [zip] https://api.github.com/repos/mongodb/mongo-php-library/zipball/3a681a3b2f2c0ebac227a3b86bb9057d0e6eb8f8 3a681a3b2f2c0ebac227a3b86bb9057d0e6eb8f8 path : /var/www/vendor/mongodb/mongodb names : mongodb/mongodb
support issues : https://github.com/mongodb/mongo-php-library/issues source : https://github.com/mongodb/mongo-php-library/tree/1.15.0
autoload files psr-4 MongoDB\ => src/
requires ext-hash ext-json ext-mongodb ^1.15.0 jean85/pretty-package-versions ^1.2 || ^2.0.1 php ^7.2 || ^8.0 symfony/polyfill-php80 ^1.19
requires (dev) doctrine/coding-standard ^9.0 squizlabs/php_codesniffer ^3.6 symfony/phpunit-bridge ^5.2 vimeo/psalm ^4.28
php --ri mongodb:
mongodb
MongoDB support => enabled MongoDB extension version => 1.15.3 MongoDB extension stability => stable libbson bundled version => 1.23.4 libmongoc bundled version => 1.23.4 libmongoc SSL => enabled libmongoc SSL library => OpenSSL libmongoc crypto => enabled libmongoc crypto library => libcrypto libmongoc crypto system profile => disabled libmongoc SASL => disabled libmongoc ICU => disabled libmongoc compression => enabled libmongoc compression snappy => disabled libmongoc compression zlib => enabled libmongoc compression zstd => disabled libmongocrypt bundled version => 1.5.2 libmongocrypt crypto => enabled libmongocrypt crypto library => libcrypto crypt_shared library version => unknown
Directive => Local Value => Master Value mongodb.debug => no value => no value
composer show jenssegers/mongodb:
name : jenssegers/mongodb descrip. : A MongoDB based Eloquent model and Query builder for Laravel (Moloquent) keywords : database, eloquent, laravel, model, moloquent, mongo, mongodb versions : * v3.9.5 type : library license : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText homepage : https://github.com/jenssegers/laravel-mongodb source : [git] https://github.com/jenssegers/laravel-mongodb.git 6ce35ace85a5946f943d7f493f93aebb9a6d129d dist : [zip] https://api.github.com/repos/jenssegers/laravel-mongodb/zipball/6ce35ace85a5946f943d7f493f93aebb9a6d129d 6ce35ace85a5946f943d7f493f93aebb9a6d129d path : /var/www/vendor/jenssegers/mongodb names : jenssegers/mongodb
support issues : https://github.com/jenssegers/laravel-mongodb/issues source : https://github.com/jenssegers/laravel-mongodb/tree/v3.9.5
autoload psr-4 Jenssegers\Mongodb\ => src/
requires illuminate/container ^9.0 illuminate/database ^9.0 illuminate/events ^9.0 illuminate/support ^9.0 mongodb/mongodb ^1.11
requires (dev) doctrine/dbal ^2.13.3|^3.1.4 mockery/mockery ^1.3.1 orchestra/testbench ^7.0 phpunit/phpunit ^9.5.8
suggests jenssegers/mongodb-sentry Add Sentry support to Laravel-MongoDB jenssegers/mongodb-session Add MongoDB session support to Laravel-MongoDB