Hello i have installed Parse server and parse sdk for php on my Linux Centos Server.
Parse Dashboard: 1.3.3,
Server version: 4.3.0
I'm managing those db's using php code. This parser was installed by someone else. The thing is I'm not sure how to install LiveQuery for my server. I don't know if my version of server is good for this kind of operations. I found some solutions how to enable this feature, but there was something like "index.js" - in my file system it's app.js. Screen of file system
In app.js i added lines:
liveQuery: {
classNames: ["Test"] //List of classes to support for query subscritions
}
I've created class in my db named "Test", then i found solution i need to add
this line
liveQueryUrl: keyLiveQueryUrl, // Required if using LiveQuery
I don't really know how to get this key.
How can i check if LiveQuery works? It will be used by flutter code, but i'd like to check it first in PHP.
My problem has been solved in my other extended topic here.
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
I'm very very new to PHP, but now I have to help my friend to solve a PHP problem.
He has bought a web site based on PHP, after he upload it to the host, found there is a error:
Fatal error: Call to undefined function json_encode() in xxx.php
The code is very simple:
echo json_encode(array(
'result' => true,
));
It send a json to client.
I know json_encode is added after php 5.2, but the PHP version of his host is PHP 5.1.2, so that's the reason why it reports error.
But we don't have the right to upgrade the PHP version of host, so I have to modify the code. How to let it return a json to client without json_encode?
The webpage in client browser will run this javascript code, to get and check that json:
jQuery.ajax({ 'url': '...', ...,
'success':function(json) {
if(json != null && json.result == true) {
// do something
}
}
}
Thanks a lot!
UPDATE
Since I have no rights to upgrade anything or install new libraries to that host, the only thing I can do is change the code. But I nearly know nothing about php, that I don't know how to use 3rd party libraries either. At last, I fix it as this:
In php:
echo '{"result":"true"}';
In javascript:
if(json!=null && json.result=="true") {
// do something
}
First of all: you should strongly consider upgrading, since PHP 5.1.x and 5.2.x are no longer supported. You indicated that you do not have the rights to do so, but if you are a paying customer, that should count for something. PHP 5.2 is deprecated as of the last PHP 5.3.6 release.
A user on PHP.net has provided for a custom function that does the same.
You could rename it to json_decode() and wrap it in a if (!function_exists('json_encode')) statement:
if (!function_exists('json_encode')) {
function json_encode() {
// do stuff
}
}
He has an older PHP version where json_encode is missing. This can be fixed with various 3rd party libraries.
A dated project of mine: http://include-once.org/p/upgradephp/ which provides a drop-in json_encode/json_decode almost identical to PHPs builtin extension (quirky in regards to Unicode).
Then there is https://pear.php.net/package/Services_JSON which even adds JSOL (Object Literals are a superset of JSON) support.
And also http://framework.zend.com/manual/en/zend.json.html which provides a class delivering a pretty thorough reimplementation. (Probably the best-tested version available.)
You can use a third party JSON library, such as the one from the PEAR project (they provide all sorts of useful PHP libraries, of varying quality):
http://pear.php.net/pepr/pepr-proposal-show.php?id=198
I'm sure there are more (I'd try searching Google for PHP JSON libraries).
Why not use a plain PHP json-library which you can include in every setup?
I googled this one here for you.
Read the comments for json_encode at http://www.php.net/manual/en/function.json-encode.php where you also find a comment containing a manual implementation for php < 5.2:
http://www.php.net/manual/de/function.json-encode.php#100835
Further there are also other implementations available via google.
jsonwrapper implements the json_encode function if it is missing, and leaves it alone if it is already present. So it is nicely future-compatible.
i had to install JSON Libs the other day on my server, try the following:
Execute the following commands:
pecl install json
touch /etc/php.d/json.ini
echo "extension=json.so" > /etc/php.d/json.ini
service httpd restart
The first will install the json libraries to your machine, the second line will create the json.ini fiel in the php.d directory and the last line will add the line extension=json.so to the json.ini file.
Hope this helps!
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.
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?