Problems with WAMP and PHP 7.2
Posted by: svent (---.92-221-87.customer.lyse.net)
Date: February 08, 2018 07:54PM

I have tried adding PHP versions 7.2, 7.2.1, 7.2.2 and latest snapshot, and with all, I am unable to use the new cryptography functionality (Sodium).

Trying to use any of the new functions like "sodium_crypto_secretbox_keygen()" etc. throw "Call to undefined function" errors.

Same with any of the predefined constants like "SODIUM_CRYPTO_AUTH_KEYBYTES", they throw a warning for "Use of undefined constant".

Note. Have tried both with and without the Sodium extension loaded, but its same result.


Do anyone have an idea how I can get this new functionality work through WAMP?

Thanks

Options: ReplyQuote
Re: Problems with WAMP and PHP 7.2
Posted by: Otomatic (Moderator)
Date: February 08, 2018 09:18PM

Hi,

Thre is no problem to use sodium.
Load the extension:
Left-Click -> PHP -> PHP extensions -> sodium to check it
Write a file wamp/www/testsodium.php with :
<?php
echo "Value of SODIUM_LIBRARY_VERSION=".SODIUM_LIBRARY_VERSION."<br>";
echo "Value of SODIUM_CRYPTO_AUTH_KEYBYTES=".SODIUM_CRYPTO_AUTH_KEYBYTES."<br>";
echo "Secret box value=".sodium_crypto_secretbox_keygen()."<br>";
?>
In the browser, type : 'http://localhost/testsodium.php' and the result is :
Value of SODIUM_LIBRARY_VERSION=1.0.16
Value of SODIUM_CRYPTO_AUTH_KEYBYTES=32
Secret box value=s��q�(�[,��o�J���"�x���~v _�

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: Problems with WAMP and PHP 7.2
Posted by: svent (---.92-221-87.customer.lyse.net)
Date: February 08, 2018 10:23PM

Thanks for the reply.

Good to hear it works on your side, manage to get it working on mine as well.

The issue was tied to the "libsodium.dll" file in the PHP folder, and as my windows Path variable was set to the folder for PHP 7.1 it did not find it, and by that did not load it. The strange part about it is that no error was thrown when it tried to load the extension, so it seemed like everything was good.


After I changed my Path variable it workes perfectly.

Options: ReplyQuote
Re: Problems with WAMP and PHP 7.2
Posted by: Otomatic (Moderator)
Date: February 08, 2018 10:51PM

Hi,

Why do you use PATH variable with path to PHP?
Wampserver does not use PATH and does not need it.
Each time you change php version you must also change your PATH.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: Problems with WAMP and PHP 7.2
Posted by: svent (---.92-221-87.customer.lyse.net)
Date: February 09, 2018 12:39AM

That is a good question, I do not remember why I added it initially. Might have been out of habit as I've always done a direct install in the past.

Tried removing the PATH variable, and it works. Thanks

Options: ReplyQuote
Re: Problems with WAMP and PHP 7.2
Posted by: Otomatic (Moderator)
Date: February 09, 2018 09:55AM

Hi,

It is a very bad way of programming to use the PATH system environment(*) variable to run an application. There are other ways to do this, especially since in 99.99% of cases, the path is not cleaned when uninstalling the application.

(*) There was no other way of doing things in the 80's with DOS; it was more than 30 years ago!

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote


Sorry, only registered users may post in this forum.