Reputation: 43
I have installed libsodium and libsodium-php on ubuntu 16.04 but when I run:
`<?php
var_dump([
\Sodium\library_version_major(),
\Sodium\library_version_minor(),
\Sodium\version_string()
]);`
I get an error saying:
PHP Fatal error: Uncaught Error: Call to undefined function Sodium\library_version_major()
According to phpinfo() Sodium is enabled and the compiled version is 2.0.1 and the library version is 1.0.13. What am I doing wrong?
Upvotes: 3
Views: 6179
Reputation: 167
For those who couldnt get the answer working.. thats because it should be:
<?php
var_dump([
SODIUM_LIBRARY_MAJOR_VERSION,
SODIUM_LIBRARY_MINOR_VERSION,
SODIUM_LIBRARY_VERSION
]);
Upvotes: 3
Reputation: 123
For those who installed Pecl Version of Soidum and Enabled it in php.ini (extension=sodium.so) And Have same error like Call to Undefined ...
After Restarting Apache & nginx and lack of success finally Reboot server get sodium work exteremly.
PHP 7.3 & >7.3 = libsodium 2.1
Hope to be helpful.
Upvotes: 3
Reputation: 1501
The PHP API for libsodium has changed in version 2.0.0 of the extension.
Originally, all functions were in a \Sodium\
namespace.
However, following a vote by PHP developers regarding its inclusion in PHP 7.2, it was decided to move everything to the global namespace instead.
So, what used to be \Sodium\library_version_major()
is now sodium_library_version_major()
.
Upvotes: 5