Unable to load PEAR extension (PHP) php81-pear-Net_GeoIP

What's installed:
php81
php81-pear
apache24
mod_php81
etc.

I need to use that specific library
php81-pear-Net_GeoIP-1.0.0.r1_1
This extension used to be located in ports 'net/GeoIP' ( https://www.freshports.org/net/GeoIP/ ), but not anymore

So I installed this extension with

Code:
[root@freebsd /usr/local/etc]# pkg install php81-pear-Net_GeoIP
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 9 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
    php81-pear: 1.10.13
    php81-pear-Cache: 1.5.6_1
    php81-pear-HTTP_Request: 1.4.4
    php81-pear-Net_GeoIP: 1.0.0.r1_1
    php81-pear-Net_Socket: 1.2.2
    php81-pear-Net_URL: 1.0.15
    php81-pear-XML_Parser: 1.3.8
    php81-pear-XML_Serializer: 0.21.0
    php81-pear-XML_Util: 1.4.5

Number of packages to be installed: 9

The process will require 3 MiB more space.
392 KiB to be downloaded.

Proceed with this action? [y/N]: y
[1/9] Fetching php81-pear-Net_Socket-1.2.2.pkg: 100%    8 KiB   7.8kB/s    00:01
[2/9] Fetching php81-pear-Net_GeoIP-1.0.0.r1_1.pkg: 100%   14 KiB  14.6kB/s    00:01
[3/9] Fetching php81-pear-HTTP_Request-1.4.4.pkg: 100%   17 KiB  17.1kB/s    00:01
[4/9] Fetching php81-pear-Cache-1.5.6_1.pkg: 100%   28 KiB  29.2kB/s    00:01
[5/9] Fetching php81-pear-Net_URL-1.0.15.pkg: 100%    7 KiB   7.4kB/s    00:01
[6/9] Fetching php81-pear-XML_Serializer-0.21.0.pkg: 100%   31 KiB  32.0kB/s    00:01
[7/9] Fetching php81-pear-XML_Util-1.4.5.pkg: 100%   18 KiB  18.6kB/s    00:01
[8/9] Fetching php81-pear-1.10.13.pkg: 100%  254 KiB 260.4kB/s    00:01
[9/9] Fetching php81-pear-XML_Parser-1.3.8.pkg: 100%   15 KiB  14.9kB/s    00:01
Checking integrity... done (0 conflicting)
[1/9] Installing php81-pear-1.10.13...
[1/9] Extracting php81-pear-1.10.13: 100%
PHP Warning:  Trying to access array offset on value of type bool in /usr/local/share/pear/PEAR/DependencyDB.php on line 173
PHP Warning:  Trying to access array offset on value of type bool in /usr/local/share/pear/PEAR/DependencyDB.php on line 177
PHP Warning:  Trying to access array offset on value of type null in /usr/local/share/pear/PEAR/DependencyDB.php on line 177
[2/9] Installing php81-pear-Net_Socket-1.2.2...
[2/9] Extracting php81-pear-Net_Socket-1.2.2: 100%
install ok: channel://pear.php.net/Net_Socket-1.2.2
[3/9] Installing php81-pear-Net_URL-1.0.15...
[3/9] Extracting php81-pear-Net_URL-1.0.15: 100%
install ok: channel://pear.php.net/Net_URL-1.0.15
[4/9] Installing php81-pear-HTTP_Request-1.4.4...
[4/9] Extracting php81-pear-HTTP_Request-1.4.4: 100%
install ok: channel://pear.php.net/HTTP_Request-1.4.4
[5/9] Installing php81-pear-Cache-1.5.6_1...
[5/9] Extracting php81-pear-Cache-1.5.6_1: 100%
install ok: channel://pear.php.net/Cache-1.5.6
[6/9] Installing php81-pear-XML_Parser-1.3.8...
[6/9] Extracting php81-pear-XML_Parser-1.3.8: 100%
install ok: channel://pear.php.net/XML_Parser-1.3.8
[7/9] Installing php81-pear-XML_Util-1.4.5...
[7/9] Extracting php81-pear-XML_Util-1.4.5: 100%
install ok: channel://pear.php.net/XML_Util-1.4.5
[8/9] Installing php81-pear-XML_Serializer-0.21.0...
[8/9] Extracting php81-pear-XML_Serializer-0.21.0: 100%
install ok: channel://pear.php.net/XML_Serializer-0.21.0
[9/9] Installing php81-pear-Net_GeoIP-1.0.0.r1_1...
[9/9] Extracting php81-pear-Net_GeoIP-1.0.0.r1_1: 100%
warning: pear/Net_GeoIP requires PHP (version >= 5.0.0, version <= 6.0.0), installed version is 8.1.32
install ok: channel://pear.php.net/Net_GeoIP-1.0.0RC1
[root@freebsd /usr/home/domains/__hosts]#

and pear said that the extension is installed.
Code:
[root@freebsd /usr]# pear list
Installed packages, channel pear.php.net:
=========================================
Package          Version  State
Archive_Tar      1.4.14   stable
Cache            1.5.6    stable
Console_Getopt   1.4.3    stable
HTTP_Request     1.4.4    stable
Net_GeoIP        1.0.0RC1 beta
Net_Socket       1.2.2    stable
Net_URL          1.0.15   stable
PEAR             1.10.13  stable
Structures_Graph 1.1.1    stable
XML_Parser       1.3.8    stable
XML_Serializer   0.21.0   beta
XML_Util         1.4.5    stable

Include_path looks fine and pointing to the right folder
.:/usr/local/share/pear
and all the files seem to be located in the right place. But I'm unable to use them in PHP code.
Code:
[root@freebsd /usr/local/etc]# php -r 'print phpinfo();' | grep PEAR
[root@freebsd /usr/local/etc]#

What am I doing wrong or what I missed?
p.s. In theory, PHP should automatically load all extensions, but it seems that this does not happen with PEAR extensions. The rest of the '*.so' extensions load normally and work as they should.
 

Attachments

  • 1.jpg
    1.jpg
    12.4 KB · Views: 117
and all the files seem to be located in the right place. But I'm unable to use them in PHP code.
Hi maks, output of phpinfo is not an example of using the class in php code. Have you used this extension before? it is a class and it requires two things: a geo database and an instance of the class must be defined. i do not see how this is related to FreeBSD.

 
>output of phpinfo is not an example of using the class in php code.
I dug through mountains of documentation and advice on websites. They say that the extension should appear in the phpinfo. Although I'm not sure.

>Have you used this extension before?
Yes. But with php 7.0 and 7.4. I think that it's a C-based extension there for those PHP versions.
Code:
$ ls -la geoip.so
-rw-r--r--  1 root  wheel  24696 Dec 14  2018 geoip.so
For PHP 8+, it's a PHP-based PEAR extension now.

> i do not see how this is related to FreeBSD.
I'm trying to run it all on FreeBSD. That's probably why this topic is related to this OS. Given that logic, then this topic https://forums.freebsd.org/threads/upgrades-to-php-installed-pear-and-now-live-site-down.95343/ also is not related to FreeBSD ? Right?
 
maks I'm a member of a php forum and if we were in that forum, i wouldn't be so nice. Have a look at my php script output using Net/GeoIP on FreeBSD. phpinfo or pear is irrelevant. However, as a php programmer, you shouldn't be using outdated versions of php. Update to 8.4 already. It is incorrect to subject users of a website to security vulnerabilities contained in outdated php software.

I use FreeBSD in VirtualBox on Windows, so i guess any problems that i have with FreeBSD are Microsoft Windows problems. :rolleyes:
 

Attachments

  • netgeoipoutputfromFreeBSDshell.jpg
    netgeoipoutputfromFreeBSDshell.jpg
    23.8 KB · Views: 131
I'm been doing PHP coding for about 25 years already (let's say that this is one of the languages I'm familiar with quite well) and have couple of my own PHP frameworks. Appreciate your recommendations, but I will stay on 8.1.
I resolved that issue different way with using of "maxmind-db/reader": "^1.12.1", vendor library with their geo ip db. Works quite well and much better than Net/GeoIP. So that I don't need any legacy geoip PHP extensions.
Thanks anyway for the response.
 
Back
Top