PHP - Call to undefined function http_inflate() - php

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.

Related

PHP Version 7.3.17 on Amazon EC2 missing sodium?

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

PHP class 'Ds\Map' not found

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

Missing XMLReader Class

I am playing around with parsing spreadsheets and found the spreadsheet-reader class. I installed and have a very simple program written to open and parse an ".ODS" spreadsheet file. When I run it I get the error:
PHP Fatal error: Class 'XMLReader' not found in...
The line in question:
$ss = new SpreadsheetReader("test.ods");
So I google around and find out the version of PHP on that system needs to be at least 5.1 for it to use the version of XMLReader built into the core of PHP. I am using 5.4.12 there. I check with php -i and find PHP was compiled with: '--enable-xmlreader=shared'. According to the docs nothing needs to be configured at runtime to enable it.
Where else can I check and what am I doing wrong?
The solution is because PHP was built with a shared object file you DO need to modify php.ini: extension=xmlreader.so.

IMagic object creation shows error?

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.

PHP Not Recognizing http_get_request_headers()?

I'm calling http_get_request_headers() in a PHP file on a server running PHP 5. However, I'm getting Fatal error: Call to undefined function http_get_request_headers(). Does anyone know what the problem might be? Does this function not come with plain PHP?
No it does not. You need a PECL module for that function to work. But you can use the contents of the $_SERVER variable as stated in this comment on the php site. Alternatively you can use the apache function if this is your web server.
If you're using version >= 2 of pecl_http you'll need to use the namespace syntax for calling the functions. Check out the version 2 documentation here and example here
Basically \http\Env::getRequestHeader()
That function is part of the PECL extension.
Follow the instructions on this page to install it: http://ar.php.net/manual/en/http.install.php
Have you read the Installation and Configuration guide for the HTTP classes/functions?

Categories