How to activate JSON module for PHP in FAMP plugin

trinxie

Dabbler
Joined
Feb 7, 2013
Messages
28
Hello,
I have successfully installed the FAMP plugin for TrueNAS-12.0-U8, but I think I need to activate the JSON module for PHP.

Problem: When testing this simple example, I get no output (except for "Hello!")
Code:
<!DOCTYPE html>
<html><body>
<?php
  echo "Hello!";
  $cars = array("Volvo", "BMW", "Toyota");
  echo json_encode($cars);
?>
</body></html>

I have not configured apache/php in a long time, so I feel lost.
Anyone have a hint how to proceed?

Code:
root@myFAMP:/usr/lib # php -m
[PHP Modules]
Core
date
hash
libxml
mysqli
mysqlnd
pcre
Reflection
SPL
standard

root@myFAMP:/usr/lib # php -ver
PHP 7.4.30 (cli) (built: Aug 13 2022 01:34:10) ( NTS )

 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
You would need to pkg install php74-json if that module is not present. I don't know if you can do that in plugins. I always roll my own jails. pkg search can help you find the names of other missing packages, in case there are more. pkg info shows you what's installed.
 

trinxie

Dabbler
Joined
Feb 7, 2013
Messages
28
You are the man, thanks :smile:

Now I got:
Code:
Hello!["Volvo","BMW","Toyota"]


As you say, maybe I roll my own jail, starting from scratch and learn more in details how to handle the installation steps.
This JSON module was the only part missing for my small project, so that is why I tried the FAMP.
During install I got the notice that the package is depricated:

Code:
[myFAMP] [1/1] Fetching php74-json-7.4.30.pkg: 100%   21 KiB  21.7kB/s    00:01
Checking integrity... done (0 conflicting)
[myFAMP] [1/1] Installing php74-json-7.4.30...
[myFAMP] [1/1] Extracting php74-json-7.4.30: 100%
=====
Message from php74-json-7.4.30:

--
This file has been added to automatically load the installed extension:
/usr/local/etc/php/ext-20-json.ini
--
===>   NOTICE:

This port is deprecated; you may wish to reconsider installing it:

Upstream Security Support ends on 2022-11-28.

It is scheduled to be removed on or after 2022-11-29.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
PHP 7.4 itself is EOL soon. You might want to install 8.1 in your own jail.
 

trinxie

Dabbler
Joined
Feb 7, 2013
Messages
28
Thanks so much for your comments !
 
Top