-1

When I try to run my PHPUnit tests on WSL (Windows Subsystem for linux). I will always get thrown this warning:

PHP Warning: PHP Startup: Unable to load dynamic library 'php_openssl.dll' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20190902/php_openssl.dll (/usr/local/lib/php/extensions/no-debug-non-zts-20190902/php_openssl.dll: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20190902/php_openssl.dll.so (/usr/local/lib/php/extensions/no-debug-non-zts-20190902/php_openssl.dll.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

I have searched through all my of .ini files to find if there is any extension=php_openssl.dll that remain without a ; before them. But found none.

If anyone could help me I would be very grateful!

Sebastian Bergmann
  • 7,837
  • 1
  • 27
  • 35
penguintr
  • 325
  • 1
  • 2
  • 14

1 Answers1

0

WSL is the "Windows Subsystem for Linux". Which means that it really is a Linux environment running in a container/VM/something like that on top of your Windows kernel.

And, in a Linux environment, DLL files ("dynamic link libraries") are not useful. The Linux equivalent are .so files ("shared objects").

You see in your warning text that the configuration specifies to load php_openssl.dll, but the PHP runtime tries to open php_openssl.dll.so -- which does not exist.

So, to have that configuration run on both Windows and Linux, you'll need to remove the file name extension from the config -- PHP will try to append either .dll or .so depending on the environment it is running in. Just try extension=php_openssl in your config files.

orithena
  • 1,455
  • 1
  • 10
  • 24
  • Yes of course. But when I change it to `extension=openssl` and re-run my tests it still gives me the same error: `PHP Warning: PHP Startup: Unable to load dynamic library 'php_openssl.dll' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20190902/php_openssl.dll (/usr/local/lib/php/extensions/no-debug-non-zts-20190902/php_openssl.dll: cannot open shared object file: No such file or directory)` – penguintr Dec 11 '19 at 10:44
  • @TobyR That almost sounds as if the PHP binary for windows is being run in the linux environment. Is any openssl dll or so floating around in that directory? Is your extension_dir set correctly? Check the answers to this related question, maybe they give you some hints on what to look at: https://stackoverflow.com/questions/5282264/php-warning-php-startup-unable-to-load-dynamic-library?rq=1 – orithena Dec 11 '19 at 11:10
  • Thank you, but unfortunately there are no `openssl.dll` files floating around and the extension, I assume is correct. I have installed php using chocolatey as it simplifies a lot of my issues. The cnf file for openssl is in the subfolder `\extras\ssl` and the openssl.dll is in the `\ext` folder (on my host machine). But I am unsure where the extensions would be on WSL? – penguintr Dec 11 '19 at 11:45
  • @TobyR Well, chocolatey is a package manager _for windows_. Inside WSL, there is another package manager of the Linux distribution you have installed in WSL. Ubuntu, maybe? Then you'll need to install the linux binary of PHP using apt _from the bash prompt inside the WSL container_ if you're determined to run PHP inside WSL. This looks like you're starting the _windows_ PHP from the _Linux environment_. Run the windows PHP without WSL or run the linux PHP from inside WSL. – orithena Dec 11 '19 at 11:59
  • I already have the linux binary of php installed on WSL. I have tried to run the PHPUnit from inside the WSL container and I still get the same issue! :/ I really don't understand this! – penguintr Dec 11 '19 at 14:21
  • @TobyR Last idea would be that PHPUnit tries to run a `php.exe`, which somehow ended up in the `$PATH` inside WSL. But I don't have any more ideas apart from sitting at your machine and just watching everything until I find the part that looks suspicious. :/ – orithena Dec 11 '19 at 14:58
  • 1
    Hmm, because I used chocolatey maybe it has the wrong path variable. I am going to check. Thank you for all your help! – penguintr Dec 12 '19 at 09:31