Questions tagged [php-extension]

The PHP language can be enhanced through the use of extensions, which provide to PHP scripts new internal functions, classes, resource types, streams (also stream wrappers and filters) and, in general, can do anything a native program would be able to do.

The PHP language can be enhanced through the use of extensions, which provide to PHP scripts new internal functions, classes, resource types, streams (also stream wrappers and filters) and, in general, can do anything a native program would be able to do. Extensions are typically written in order to:

  • Wrap a native library, which is typically written in C or C++.
  • Implement PHP code in a language that offers more optimization opportunities, such as C, so that pages can be served faster and/or more pages can be served concurrently.
  • Implement/functions classes that, being closer to PHP's core, are able to do things that would otherwise not be possible (e.g. add/remove functions from the function table dynamically, bypass open_basedir).

PHP is written in C and has a C API available for extensions, therefore these tend to be written in that language. However, the only requirement is that the resulting extension is able to interface with PHP's APIs, handle its data structures and can be loaded by PHP's extension loading mechanism.

SWIG can be used to wrap native libraries in an easier fashion. See also PHP4Delphi, which allows embedding PHP in Delphi and other applications as well as writing PHP extensions in Delphi.

A special type of extensions, Zend extensions, are more tightly coupled with PHP and are provided with more hooks so that they can modify PHP's behavior more extensively. They are typically used to implement debuggers (e.g. XDebug).

Unfortunately, there is no official and up-to-date reference on how to write PHP extensions. However, see this answer for several resources.

1016 questions
3
votes
2 answers

Redis.dll not found for php8.2

I am experiencing difficulties starting Redis 5.3.7 with PHP 8.2 on my Windows machine. When I attempt to start it, a dialog box displays with the message: "The procedure entry point _zend_get_parameters_array_ex could not be located in the dynamic…
GanesH RahuL
  • 431
  • 5
  • 16
3
votes
2 answers

is it possible to have multiple classes inside php extension?

I would like to wrapp a .cc code that contains multiple public classes. Is it possible to do that ? how? Do I need to use multiple .cc files one for each class that i want to wrapp? THX
sunset
  • 1,359
  • 5
  • 22
  • 35
3
votes
1 answer

add two shared libraries in php extension. WHO?

I have a sharedlib.cc and a sharedlib.h code that contains classes and methods. I wrap this up and created a shared library called MySharedLibrary.so. I would like to work with my .so library inside a php code. So I've created a config.m4 file , a…
sunset
  • 1,359
  • 5
  • 22
  • 35
3
votes
2 answers

No performance gain with APC on WampServer

I'm working on a Windows workstation, on which I use WampServer as my development platform, to write PHP applications which are then run on Linux. I'm pretty used to APC on Linux, which is blazing fast and a must have for me. However, I'm always…
BenMorel
  • 34,448
  • 50
  • 182
  • 322
3
votes
2 answers

How to use ssh2 in PHP 8.0?

I read through all the incompatibilities prior to installing php 8 updates only to find out way too late that there is no support for the ssh2 extension yet that I can find. I am hoping that I am just missing something. I have been googling for a…
Owen Parker
  • 253
  • 2
  • 12
3
votes
1 answer

Issues installing pgsql extension for PHP 7.3.24 on Mac Big Sur using homebrew

Does anyone know the commands to get the pgsql extension installed on a Mac? Trying to use Homebrew but no luck. I suspect the commands or way I'm trying to get the extension are incorrect. I tried: brew install php@7.3-pgsql brew install…
anonymous
  • 161
  • 3
  • 11
3
votes
0 answers

Segfault in PHP without php error log. How to debug?

I have a script using com_dotnet, that makes PHP segfault (not sure if segfault is the technical correct term) under certain circumstances. Using PHP 7.4.2 NTS 32bit on Windows 2019 64bit. The same error happens when using FCGI or CLI. The same…
Lorenz Meyer
  • 19,166
  • 22
  • 75
  • 121
3
votes
0 answers

What are the specific steps to enable the ZeroMQ extension for PHP 7.3?

I am trying to enable the ZeroMQ extension for PHP on Windows. I've got a PHP 7.3 ZTS installation on my x64 Windows 10. Since the official zeromq/php-zmq is no longer maintained, I've tried using the latest release from alexat/php-zmq, but to no…
Kubo2
  • 331
  • 3
  • 16
3
votes
0 answers

How to install PHP enchant and pspell extension in heroku?

I'm trying to install PHP enchant and pspell extension in heroku runtime via composer but heroku default doesn't support pspell and enchant extension. you can see all list on their Extensions Support List page. So how do I install these…
3
votes
1 answer

How to install/enable Tidy extension in PHP 7.2 on Ubuntu 14.04?

Problem: Using tidy_parse_string() returns: call to undefined function Tried: Searching: apt-cache search tidy But i only see this php extension in the returned list : php5-tidy - tidy module for php5 How do i install the module for PHP 7.2? I…
lowkey
  • 334
  • 1
  • 7
  • 17
3
votes
1 answer

Error: Class 'SplEnum' not found in PHP 7

I have a project with PHP 7.3, under Windows 10. I use the PHP from Xampp. I get the following error: Fatal error: Uncaught Error: Class 'SplEnum' not found in [...] for class BanLevel extends SplEnum { ... } It seems I am misunderstanding the…
jasie
  • 2,192
  • 10
  • 39
  • 54
3
votes
4 answers

can't install webpay extension with php?

I am trying to install webpaySWIG extension in my local but it shows some errors. what i have done is cd webpaySWIG-3.2 (this is the location for extesion) sudo make -f makefilePhp5 (this command is mentioned in their document) while compiling I…
Ayyappadhas
  • 330
  • 1
  • 2
  • 9
3
votes
1 answer

PHP extensions not installed / loaded / enabled, using the official PHP docker image

I've been trying all day long to install some PHP extensions into a custom made docker image (based on the official php:7.1.21-fpm-alpine3.8 image), but without success. I really don't know what I'm doing wrong as I was able to do the same thing in…
mattyh88
  • 1,585
  • 5
  • 26
  • 48
3
votes
0 answers

Where can I find php_svn.dll

I recently upgraded to PHP 5.3.5 for windows. I have used the subversion extension on previous versions, but php_svn.dll is not included in the 5.3.5 version. I tried to copy the dll from the previous installation of php, but I get this message when…
Björn
  • 49
  • 1
  • 3
3
votes
1 answer

PHP extension: why int var changes to 0?

I am developing some PHP extension on C. I have few functions and several variables (char and int) defined globally at the top of C code. At php side I call the first function and pass some value for ssh_port argument - 22. this value set to global…
Mikael
  • 1,209
  • 1
  • 16
  • 47