0

When I compile phpmod with php 5 (or 5.6) everything works fine. But when I install php7.2 the php ESL doesnt work any more.

It turned out that in ESL.php is using dl() to dynamically load extension at runtime. However, the dl() option was removed in later verisons of php.

Here is the output of

# ./single_command.php status

PHP Warning: dl(): Dynamically loaded extensions aren't enabled in 
/usr/src/freeswitch/libs/esl/php/ESL.php on line 24 
Command to run is: status 
PHP Fatal error: Uncaught Error: Call to undefined function 
new_ESLconnection() in /usr/src/freeswitch/libs/esl/php/ESL.php:157 
Stack trace: 
#0 /usr/src/freeswitch/libs/esl/php/single_command.php(9): 
ESLconnection->__construct('127.0.0.1', '8021', 'ClueCon') 
#1 {main} 
thrown in /usr/src/freeswitch/libs/esl/php/ESL.php on line 157 

I tried to load ESL.so extension in php.ini but that does not work either.

Here is the output:

# php -dextension=/usr/lib/php/20160303/ESL.so 

PHP Warning: PHP Startup: ESL: Unable to initialize module 
Module compiled with module API=20131226 
PHP compiled with module API=20170718 
These options need to match 
in Unknown on line 0 

Any idea to get ESL PHP working with php7.2?

I need to use php > 7.1.3 (web framework requirement)

PS: I opened a ticket on JIRA but I got nothing back yet.

https://freeswitch.org/jira/browse/ESL-132

Anis Bedhiafi
  • 185
  • 1
  • 5
  • 22

1 Answers1

1

You need to compile ESL.so after having installed the PHP 7.2 development setup in order to avoid the API compilation mismatch error, and load the ESL.so extension in your php.ini file under the [PHP] section using a extension= statement.

Here is what I have as an example :

[PHP]
...
extension=/usr/local/src/freeswitch-git/libs/esl/php/ESL.so
...

/usr/local/src/freeswitch-git/ is FreeSWITCH's source directory, and ESL.so has been compiled with make phpmod in /usr/local/src/freeswitch-git/libs/esl.

Some useful commands along the way :

# list the compiled extensions/modules (ESL would be listed here on success)
php -m
# detailed PHP configuration
php -i
# get the API option in the compiled ESL module (adapt to your case)
strings /usr/local/src/freeswitch-git/libs/esl/php/ESL.so | grep API

Hope this helps!

Philippe Sultan
  • 2,111
  • 17
  • 23
  • Hi Philippe. Thank you for the answer. Actually I tried that before but it didn't work. Unfortunately I still get a mismatch. Yes I installed php7.2 before compiling. The problem is in the /usr/src/freeswitch/libs/esl/php/ESL.php file (building Freeswitch from source). // PHP_SHLIB_SUFFIX gives 'dylib' on MacOS X but modules are 'so'. if (PHP_SHLIB_SUFFIX === 'dylib') { if (!dl('ESL.so')) return; } else { if (!dl('ESL.'.PHP_SHLIB_SUFFIX)) return; } the dl() is the one causing problems. – Anis Bedhiafi Mar 06 '18 at 01:01
  • Here is what I am using for the moment. The old fashion way of sockets: https://hotexamples.com/examples/-/event_socket/reset_fp/php-event_socket-reset_fp-method-examples.html – Anis Bedhiafi Mar 06 '18 at 01:03
  • Hi Anis, did you download FreeSWITCH and ran `./bootstrap.sh` + `./configure` after having installed PHP ? You may want to grep `php` in the generated `/usr/src/freeswitch/libs/esl/php/Makefile` in order to check that the various files there refer to the proper PHP version. – Philippe Sultan Mar 06 '18 at 08:44
  • Yes Phillipe of course I run ./bootstrap to pick up headers, ./configure, make && make install – Anis Bedhiafi Mar 06 '18 at 17:15