mongodb / mongo-php-driver

The Official MongoDB PHP driver
https://pecl.php.net/package/mongodb
Apache License 2.0
889 stars 204 forks source link

PHP startup warning: Unable to load dynamic library 'mongodb' #1155

Closed ghost closed 4 years ago

ghost commented 4 years ago

Bug Report

I am trying to create a project using php and mongodb's php driver. When I try to install the library with composer, composer gives me an error saying that I need to install the mongodb extension for php. So I go to pecl.php.net to install the php extension. But php gives me an error saying that the extension was not found (Debug output mentioned under debug log). I have even tried following the steps in #677, but it doesn't work. I haven't experienced this issue before with older versions of the extension

Environment

Environment Info:

Click to expand
Operating System: Windows 10 x64
PHP Version: 7.4.8
PHP mongodb ext version: 1.7.5
MongoDB version: 4.2.6

Have you installed php using a third-party service like MAMP or XAMPP?

No

Test Script

The problem was not caused by any php scripts

Expected and Actual Behavior

Expected behaviour:

PHP should have loaded the extension without any 404 warnings outputted

Actual behaviour

PHP says that the extension was not found according to the debug output mentioned under the debug log category

Debug Log

Here is the debug log outputted by php when the problem occured:

PHP Warning:  PHP Startup: Unable to load dynamic library 'mongodb' (tried: ext\mongodb (The specified module could not be found.), ext\php_mongodb.dll (The specified module could not be found.)) in Unknown on line 0
jmikola commented 4 years ago

But php gives me an error saying that the extension was not found (Debug output mentioned under debug log).

Is this error from the web environment, CLI environment (i.e. php.exe), or both?

For each environment where this error occurred, can you share your phpinfo() output? Feel free to only include INFO_GENERAL and INFO_CONFIGURATION (i.e. phpinfo(INFO_GENERAL|INFO_CONFIGURATION)) as the PHP platform details and INI configuration are most relevant here.

Additionally, can you link to the exact archive of the extension that you've downloaded (from PECL) and indicate the full path where you've extracted the DLL?

ghost commented 4 years ago

Is this error from the web environment, CLI environment (i.e. php.exe), or both?

@jmikola Yes, from php.exe, the web environment and wherever I use php like in debugging, installing packages using composer, etc

Just gimme a few minutes and I'll share the info right away

ghost commented 4 years ago

Here is a screenshot of INFO_GENERAL (general info):

php_general

I need some time to get the config info (INFO_CONFIGURATION)

ghost commented 4 years ago

Ok here is the config info (INFO_CONFIGURATION):

Directive Local Value Master Value
allow_url_fopen On On
allow_url_include Off Off
arg_separator.input & &
arg_separator.output & &
auto_append_file no value no value
auto_globals_jit On On
auto_prepend_file no value no value
browscap no value no value
default_charset UTF-8 UTF-8
default_mimetype text/html text/html
disable_classes no value no value
disable_functions no value no value
display_errors On On
display_startup_errors On On
doc_root no value no value
docref_ext no value no value
docref_root no value no value
enable_dl Off Off
enable_post_data_reading On On
error_append_string no value no value
error_log no value no value
error_prepend_string no value no value
error_reporting 32767 32767
expose_php On On
extension_dir ext ext
file_uploads On On
hard_timeout 2 2
highlight.comment #FF8000 #FF8000
highlight.default #0000BB #0000BB
highlight.html #000000 #000000
highlight.keyword #007700 #007700
highlight.string #DD0000 #DD0000
html_errors On On
ignore_repeated_errors Off Off
ignore_repeated_source Off Off
ignore_user_abort Off Off
implicit_flush Off Off
include_path .;C:\php\pear .;C:\php\pear
input_encoding no value no value
internal_encoding _no value_ _no value_
log_errors On On
log_errors_max_len 1024 1024
mail.add_x_header Off Off
mail.force_extra_parameters no value no value
mail.log no value no value
max_execution_time 30 30
max_file_uploads 20 20
max_input_nesting_level 64 64
max_input_time 60 60
max_input_vars 1000 1000
memory_limit 128M 128M
open_basedir no value no value
output_buffering 4096 4096
output_encoding no value no value
output_handler no value no value
post_max_size 8M 8M
precision 14 14
realpath_cache_size 4096K 4096K
realpath_cache_ttl 120 120
register_argc_argv Off Off
report_memleaks On On
report_zend_debug Off Off
request_order GP GP
sendmail_from no value no value
sendmail_path no value no value
serialize_precision -1 -1
short_open_tag Off Off
SMTP localhost localhost
smtp_port 25 25
sys_temp_dir no value no value
syslog.facility LOG_USER LOG_USER
syslog.filter no-ctrl no-ctrl
syslog.ident php php
track_errors Off Off
unserialize_callback_func no value no value
upload_max_filesize 2M 2M
upload_tmp_dir no value no value
user_dir no value no value
user_ini.cache_ttl 300 300
user_ini.filename .user.ini .user.ini
variables_order GPCS GPCS
windows.show_crt_warning Off Off
xmlrpc_error_number 0 0
xmlrpc_errors Off Off
zend.assertions 1 1
zend.detect_unicode On On
zend.enable_gc On On
zend.exception_ignore_args Off Off
zend.multibyte Off Off
zend.script_encoding no value no value

Additionally, can you link to the exact archive of the extension that you've downloaded (from PECL) and indicate the full path where you've extracted the DLL?

I didn't get you there. Can you explain?

jmikola commented 4 years ago

Additionally, can you link to the exact archive of the extension that you've downloaded (from PECL) and indicate the full path where you've extracted the DLL?

I'm referring to the archive you downloaded https://pecl.php.net/package/mongodb/1.7.5/windows.

Based on your phpinfo() output, you're running PHP 7.4 without thread-safety (i.e. NTS) on an x64 architecture. I would expect that you have downloaded php_mongodb-1.7.5-7.4-nts-vc15-x64.zip but I'd like to confirm.

I also see that your extension_dir INI setting is set to ext. This comment on PHP.net suggests changing that to an absolute path as a possible workaround.

ghost commented 4 years ago

@jmikola Thank you so much for your help! Tbh I had downloaded the thread-safe version of the php_mongodb.dll extension by mistake, when I actually have a Non thread-safe version of php on my computer Lol!

You can close this issue now. My problem has been solved.