When making call to sodium_crypto_pwhash_str I get the following in my Apache error log file.
PHP Fatal error: Uncaught Error: Call to undefined function
sodium_crypto_pwhash_str()
My php version, as noted is 7.3.17 running on an Amazon EC2 instance.
My php-info() does not return any relevant libsodium information other than module author info:
Sodium Frank Denis
Given the above author information references a module author am I supposed to enable the sodium module? If the answer is yes is it referenced in the php.ini file? Such as:
extension=sodium
or perhaps:
extension=libsodium
What am I missing here?
Am I not supposed to use the documented function sodium_crypto_pwhash_str?
Am I supposed to use some other method of accessing the desired functionality?
Yes normally it's included in PHP 7.2+ but when you use the AWS EC2 instances this is a bit minimalistic and not everything is included.
https://www.php.net/manual/de/sodium.installation.php
Here you can see that you have to enable it during the compiling with --with-sodium[=DIR]. So you can compile it on your own or you try another distro to get it from your package manager or you use another lib to make it work.
https://forums.aws.amazon.com/thread.jspa?threadID=293187
Related
In PHP (version 7.1), I am attempting to use a MAP as opposed to a two dimensional array to handle implicit data type conversion across different data type groups. However, I am receiving the following run-time error:
Class 'Ds\Map' not found
The error occurs on this line of code:
protected $hive_data_type_group_map = new \Ds\Map();
I have checked online, but there is little documentation on Ds\Map, even on PHP's website (click here). Does anyone know how to fix this?
Data Structures is not a built-in PHP extension.
It needs to be installed before use. The installation instructions are available on php.net.
For windows
Download compiled-dll file "php_ds.dll" from https://pecl.php.net/package/ds. Place it in your dir wamp\bin\php\[your_php_version_folder]\ext and include it in your ".ini" file.
It worked for me.
the easiest way on ubuntu:
pecl install ds
Reference: https://www.php.net/manual/en/ds-deque.allocate.php
I installed the MongoDB PHP driver on Windows 10 (I'm using WAMP equipped with PHP 5.6.25. following the istructions I found at http://php.net/manual/en/mongodb.installation.windows.php and I installed also the libbson and libmongoc libraries (requested as requirements) as written at http://php.net/manual/en/mongodb.requirements.php.
Then, I added the bin folders of MongoDB, libbson and libmongoc to system path.
However, even if I can see the php_mongodb extension in the extensions list of WAMP, launching phpinfo() the mongo extension doesn't appear with the others.
Furthermore, tryng to connect to my database with
<?php
$mongo=new MongoClient("");
$db=$mongo->galileo;
$collection= $db->items;
print_r("Number of documens: "); ?>
I got the error
Fatal error: Class 'MongoClient' not found in C:\wamp64\www\galileo\index.php >on line 21
At a first look, reading this error, it might seem like that PHP is looking for php_mongodb extension in the uncorrect folder i.e. C:\wamp64\www\galileo\index.php (where the index page of my project is placed) instead of the correct one C:\wamp64\bin\php\php5.6.25\ext where all the extensions are.
But, looking at php log file php_error.log I find also a warning that says:
PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp64/bin/php/php5.6.25/ext/php_mongodb.dll' - Il sistema operativo non pu� eseguire %1.
in Unknown on line 0.
(for not Italian speaking, the phrase after - means the operating system can't execute %1, even if I can't imagine what %1 stands for).
Even using the new class MongoDB\Driver\Manager I get the error
Fatal error: Class 'MongoDB\Driver\Manager' not found in C:\wamp64\www\galileo\index.php on line 21
and the same warning.
Do you notice some error or forgetfulness in the installation process as I described and, if not, do you know how to fix the problem?
The problem is certainly related to WAMP and I think is related to the multiple php.ini in his folders. In fact, in the apache folder you can find a php.ini file that cannot be modified, otherwise nothing works at all; at the same time any changes made to the php.ini file in the php folder seems have no effect except making appear the mongodb extension in the extensions list.
So, I try using XAMPP, as suggested in this video tutorial and it works. Using Composer I was able to install also the PHP library and not only the driver.
you should not use 'MongoClient class' anymore, this extension that defines this class is deprecated. look at here.
instead, you should use MongoDB\Driver\Manager class. please read http://php.net/manual/en/class.mongodb-driver-manager.php.
and the setup must be like this in php:
$mongo = new MongoDB\Driver\Manager("mongodb://localhost:27017");
And if you still use the old class; you either need to install the old legacy extension (pecl install mongo) and use PHP 5.x, or update your code to use this new driver's classes as the old driver is not available for PHP 7. There is an upgrade guide at here.
the last part is from derickr's answer in this issue on github: https://github.com/mongodb/mongo-php-driver/issues/300
This is a bit of a weird one, so please bear with me.
I'm trying to get Bugsnag up and running on our custom platform.
The boilerplate code looks like:
if ( !include_once($NP->settings->paths->external .'/Bugsnag/guzzle.phar') )
exit('Failed to load ERROR: guzzle');
if ( !include_once($NP->settings->paths->external .'/Bugsnag/bugsnag.phar') )
exit('Failed to load ERROR SYSTEM: bugsnag');
This unfortunately throws an exception:
Fatal error: require(): Failed opening required 'phar://guzzle.phar/autoloader.php'
However, if I attempt to load this outside of our platform, it seems to spin up just fine.
As I am not thoroughly familiar with the ins and outs of working with phar's, what could we be setting which would interfere with a phar's ability to reference inside it's own container?
Information:
Ubuntu 16.04.2 LTS
PHP 7.0.18-0ubuntu0.16.04.1 (Phar is native)
Phar EXT version: 2.0.2
Phar API version: 1.1.1
Phar-based phar archives: enabled
Tar-based phar archives: enabled
ZIP-based phar archives: enabled
gzip compression: enabled
bzip2 compression: disabled
Native OpenSSL support: enabled
phar.readonly: On
phar.require_hash: Off
Any assistance will be appreciated.
Thanks!
UPDATE: After doing some testing with a colleague, I noticed that even putting the boilerplate code at the very top of our primary platform boot script, still threw the error. The only thing we could think of which changes in that case is a directory change (as the boot script is in the include_path). After adding the external directory to php's include_path, it seemed to work. I am confused by this however, because it is my understanding that Phar files are self-contained to specifically not have issues like this. Why would a Phar file suddenly be unable to reference itself, after it has already be successfully included?
UPDATE: So, the above update is not an actual fix. The results are very strange. It will spin up fine one time, then fail the next few times. Again, this is when there is no other code loading before it. Something interesting: If we restart Apache, it loads on the first page load. Everything after that it fails.
Is guzzle.phar a symlink to a file with a different name?
Otherwise you can break internal linking in .phar files by setting a different alias when loading them through the Phar class:
new Phar('guzzle.phar, 0, 'differentalias.phar');
Not sure, but I think you cannot reference a PHAR from inside another PHAR.
Why not use a usual setup with Composer (to install all the deps) and then create a PHAR using Box project?
i am trying to create a module that makes a call to the stackexchange API which returns a gzipencoded or a deflated Json response. to decompress it i am using the method http_inflate but i am getting the following error:
Fatal error: Call to undefined function http_inflate()
Is this method dependent on any library or extension?
I am running PHP 5.3.13
http_inflate is not bundled with PHP. It is part of the HTTP library. See this page for instructions on how to install it.
You need to install the HTTP extension, as seen in the link below:
PHP.net: Installing the HTTP plugin
You need to install an extension (pecl_http). See here on php.net for information.
I just try to integrate ImageMagick into my PHP project. I installed and just execute the sample files that they provided with the imagick-3.0.0RC1 zip file. But it shows
Fatal error: Class 'Imagick' not found in C:\wamp\www\imagick-3.0.0RC1\imagick-3.0.0RC1\examples\watermark.php on line 9
this kind of an error how can I avoid that. I cant see any class including section on that page. How to include the class files.
You need to install the ImageMagick PHP extension. According to the manual there is no prebuilt extension for Windows so you'll probably have to configure and compile it yourself.