Closed lzao closed 4 years ago
Are you adding the ServiceProvider? Update your mongodb driver
For me the same problem, but in migration and seeding it works but not in the website
Duplicate of #1163
iI have the same problem, please help me one
@doliskani do you have the mongodb extension installed and activated?
Yes I did. I use Laravel 5.7 and my php version is 7.2.4 and also mongodb extension is Thread Safe (TS) x64 version 1.5.3
Please share the output of php -m
command share more information about OS i suspect that you use Windows and you need the 32 bits versión of driver
C:\wamp64\bin\php>php -m [PHP Modules] bcmath bz2 calendar Core ctype curl date dom exif fileinfo filter gd gettext gmp hash iconv imap intl json ldap libxml mbstring mysqli mysqlnd openssl pcre PDO pdo_mysql pdo_sqlite Phar readline Reflection session SimpleXML soap sockets SPL standard tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zip zlib
[Zend Modules]
I don't understand why it does't display Mongo at here but it is shown in the output of the phpinfo()
Please follow the issues:
None of the above links resolved my issue I installed jenssegers as follows : composer require jenssegers/mongodb --ignore-platform-reqs Can it help to solve?
I can store the information using the command line, but I can't in Laravel, where is the problem? and i added Jenssegers\Mongodb\MongodbServiceProvider::class, in service provider
Please install without the --ignore-platform-reqs, please share the output of command php --ini
Thanks
I'm really helpless, why this error does not fix
I'm really helpless, why this error does not fix
You need to update your mongodb extension.
hi all, i was trial and error how to find solutions Class 'MongoDB\Driver\Manager' not found i just flow the machine (macbook air with mojave), MAMP + php7.1.19, another php installed 7.2.7, but in MAMP i used 7.1.19 as default.
First problem : i cant do composer install/update, since use jenssegers/mongodb
,
machine said, i need an extension for mongodb support,
First solved : research how to install this extension to my default php installed.
solved by (http://php.net/manual/en/mongodb.installation.manual.php)
`Manually Installing the MongoDB PHP Driver
$ git clone https://github.com/mongodb/mongo-php-driver.git $ cd mongo-php-driver $ git submodule update --init $ phpize $ ./configure $ make all $ sudo make install`
If you have problem with configure, just do :
$ brew install autoconf
then i check file mongodb.so in php/php7.1.19/lib/php/extensions/no-debug-non-zts-20160303
has already created.
i check php.ini too (php/pph7.1.19/conf), make sure that extension. But I remember I was wrote this line before (another research) :
extension=mongodb.so
in ; Extensions
groups.
I just double check.
Second problem,
I check phpinfo in browser, I’m not find word as mongo, I’m little frustate. Huuftt.
Ok, I check php -m
in terminal, no mongo found too.
Im going to try run mongod
in terminal. Then recheck last action : phpinfo + php -m
. Result shown me more frustation.
The research (mac) :
I found in folder php/pph7.1.19/conf
there are files :
OK..I wrote a line extension for mongo too, like before. Then restart server (in MAMP) & check phpinfo : mongodb show detailed. I think I was success then happy,
Back to terminal and check php -m
, no mongo again. Huuuft
i research by delete temp file (backup before) then do some last step, but not working, so i restore file and recheck
Final
Wait…I check php —ini
result:
Configuration File (php.ini) Path: /Applications/MAMP/bin/php/php7.1.19/conf Loaded Configuration File: /Library/Application Support/appsolute/MAMP PRO/conf/php7.1.19.ini
Loaded conf different with conf file.
so…I get this file, to add line extension=mongodb.so
, I hope this make sense.
Result
Restart server and re-check like before, hahahahaha… mongo is running.
Phpinfo and php module should be show mongo
NOTE : mongod
still running on other tab in terminal. You can check in browser as http://127.0.0.1:27017/
To make sure mongodb already in machine what I expected for my app (Laravel 5.6 + postgre + mongodb for logging).
php artisan migrate:fresh —seed
get successfull.
btw..thanks for all, for comments.
Im a amateur for this case, im newbie for Mac, this first half-year using Mac-OS. I hope some friends can explain in advanced. 👯♂️
sorry late, composer update
successfull while mongo client was running,
http://127.0.0.1:27017/
shown
It looks like you are trying to access MongoDB over HTTP on the native driver port.
Laravel Version: 5.7 PHP Version:7.1 Laravel-admin: latest
After first installing https://github.com/jenssegers/laravel-mongodb
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) Call to a member function prepare() on null
Symfony\Component\Debug\Exception\FatalThrowableError …/vendor/laravel/framework/src/Illuminate/Database/Connection.php326
vendor/laravel/framework/src/Illuminate/Database/Connection.php
any solution?
I'm facing the same issue and this doesn't have any direct relation with your PHP Mongo DB driver, I'm running the project inside a docker self container environment and the issue still happening (I'm running the composer inside the same Docker context).
I'm using PHP 7.4 with Laravel's latest version.
When I downgraded to PHP 7.1 it worked fine.
I guess the issue there's a relation with PHP version itself than with MongoDB, anyway, this does not only happen when I do composer require
This issue is very common with this library and usually, my solutions are going to the core of the library and change everything by myself and sometimes when I run the composer <require/update/remove>
The issue in my case is on the file vendor/mongodb/mongodb/src/Client.php line 107 on the constructor function, code bellow:
public function __construct($uri = 'mongodb://127.0.0.1/', array $uriOptions = [], array $driverOptions = [])
{
$driverOptions += ['typeMap' => self::$defaultTypeMap];
if (isset($driverOptions['typeMap']) && ! is_array($driverOptions['typeMap'])) {
throw InvalidArgumentException::invalidType('"typeMap" driver option', $driverOptions['typeMap'], 'array');
}
$this->uri = (string) $uri;
$this->typeMap = isset($driverOptions['typeMap']) ? $driverOptions['typeMap'] : null;
unset($driverOptions['typeMap']);
$this->manager = new Manager($uri, $uriOptions, $driverOptions);
$this->readConcern = $this->manager->getReadConcern();
$this->readPreference = $this->manager->getReadPreference();
$this->writeConcern = $this->manager->getWriteConcern();
}
For some reason, the Driver Manager is gone (and I tried to search and the driver is really gonne, why removed?!).
Anyway, for now, the only solution it seems like we have to downgrade to 3.5 and wait for the fix.
@Messhias show example for docker-compose configuration and steps for reproducing problem
@Messhias show example for docker-compose configuration and steps for reproducing problem
Do you mean you need the Dockerfile configuration?
@Messhias show example for docker-compose configuration and steps for reproducing problem
Do you mean you need the Dockerfile configuration?
Yes and versions for php mongo driver and extension
@Messhias show example for docker-compose configuration and steps for reproducing problem
Do you mean you need the Dockerfile configuration?
Yes and versions for php mongo driver and extension
@Smolevich All the necessary information you can found out in my dev Dockerfile, unfortunately, I cannot share the production one as per classified issues, but the only difference between the 2 files are the ENV vars which there's no relation with the issue that we're facing right now.
In fact, I strongly suggest use this Dockerfile in future versions of the library but this is the one that I use when the library broken or some unfixed issue happens to debug by myself and change the core.
FROM devilbox/php-fpm-7.4:latest
# opcache configurations.
ENV PHP_OPCACHE_VALIDATE_TIMESTAMPS="1" \
PHP_OPCACHE_MAX_ACCELERATED_FILES="33531" \
PHP_OPCACHE_MEMORY_CONSUMPTION="2048" \
PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10" \
PHP_OPCACHE_FILE_OVERRIDE=1
# updating the S.O.
RUN apt-get update
# installing the apt-utils package.
RUN apt-get update -y && apt-get install -y --no-install-recommends apt-utils
# installing the pdf libraries.
RUN ln -s /usr/local/bin/wkhtmlto /usr/bin/wkhtmltopdf
RUN apt-get install -y xvfb libfontconfig wkhtmltopdf
# getting the dependencies
RUN apt-get install -y zlib1g-dev \
libjpeg-dev \
libpng-dev \
libfreetype6-dev \
libreadline-dev \
libjpeg62-turbo-dev \
libonig-dev \
build-essential \
libzip-dev
# updating the dependencies.
RUN apt-get update -y
# Install Dependencies
RUN ACCEPT_EULA=Y apt-get install -y \
unixodbc \
unixodbc-dev \
libgss3 \
odbcinst \
locales \
&& echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen
RUN ln -s /usr/lib/x86_64-linux-gnu/libsybdb.a /usr/lib/
RUN apt-get update -y \
&& apt-get install -y libmcrypt-dev \
&& rm -rf /var/lib/apt/lists/* \
&& pecl install mcrypt-1.0.2 \
&& docker-php-ext-enable mcrypt
# turning on the extensions
RUN docker-php-ext-install gd
RUN docker-php-ext-install opcache
# install mongodb library
RUN apt-get update -y
RUN apt-get -y install gcc make autoconf libc-dev pkg-config libssl-dev
RUN pecl install mongodb
RUN docker-php-ext-install bcmath
RUN echo "extension=mongodb.so" >> /usr/local/etc/php/conf.d/mongodb.ini
# Install Laravel dependencies
RUN docker-php-ext-install iconv mbstring \
&& docker-php-ext-install zip \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install gd
# enable the redis extension.
RUN pecl install -o -f redis \
&& rm -rf /tmp/pear \
&& docker-php-ext-enable redis
# copying custom php.ini configurations into the container.
COPY docker/php/conf.d/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
# adding the bmacth extension for telescope watcher
RUN docker-php-ext-install bcmath
# creating the working DIR
RUN mkdir -p /code
ENV HOME=/code
WORKDIR $HOME
# setting the default user into the working dir
USER root
COPY ./ $HOME
Any updates about this issue?
@Smolevich let's continue this discussion by slack and let's hope to @jenssegers accept the propose.
Hello,
This has nothing to do with this library, it's an issue with missing/incorrect settings for mongodb extension. For more information see: https://jira.mongodb.org/browse/PHPC-656
Thanks.
If you get this error, even after you installed the Mongodb driver for php, just install mongodb using composer.
composer require mongodb/mongodb
After that this will solve your problem.
I had the same issue. I have solved it changing the permissions on the library mongodb.so, because after the installation the file had 644 and I changed to 755 and it worked.
I had the same issue and the following two commands solved my issue
sudo apt-get install php-mongodb
sudo service apache2 restart
i am have a same issue
php7.3 -m
PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: /usr/lib/php/20180731/mongodb.so (/usr/lib/php/20180731/mongodb.so: undefined symbol: ns_parserr), /usr/lib/php/20180731/mongodb.so.so (/usr/lib/php/20180731/mongodb.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[PHP Modules]
calendar
Core
ctype
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
intl
json
libxml
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache
If your using valet, restart it after installation.
Class "MongoDB\Driver\Manager" not found this error new laravel Version please help me my new error in terminal error this PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb' (tried: C:\xampp\php\ext\mongodb (The specified module could not be found), C:\xampp\php\ext\php_mongodb.dll (The specified module could not be found)) in Unknown on line 0 php version PHP 8.2.4 laravel version latest
did you fixed this problem!
yes
On Tue, Apr 2, 2024 at 5:56 AM latifaChakir @.***> wrote:
did you fixed this problem!
— Reply to this email directly, view it on GitHub https://github.com/mongodb/laravel-mongodb/issues/1358#issuecomment-2030844725, or unsubscribe https://github.com/notifications/unsubscribe-auth/A75FUI2J2IWTFPZ3X7DI5MLY3H3JTAVCNFSM4ECQP7O2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBTGA4DINBXGI2Q . You are receiving this because you commented.Message ID: @.***>
Hello, I'm using Php7.1, Laravel 5.5, and Mongo 3.4.10 as Dockers.
In the
.../vendor/mongodb/mongodb/src/Client.php
file, the corresponding FatalThrowableErrorClass 'MongoDB\Driver\Manager' not found
appears on line 83.In the Model
I used the code,
In the Controller,
I used the code.
The database.php file contains
I put this code in it.
I've been looking for the same error since yesterday, but it's still the same. Help is urgently needed.