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
6
votes
1 answer

How to install PHP 7 extension "memcache" on Windows

I'm having huge problems installing memcached extension for php. Currently using: OS: Windows 10 x64 PHP: 7.0.1 via XAMPP Apache: 2.4.18 (Win32) I have successfully installed memcached in C:/memcached the service is running. But the problem starts…
Mihailo
  • 4,736
  • 4
  • 22
  • 30
6
votes
1 answer

Enabling DOTNET COM extension in PHP 5.6.12

In a PHP project I need to use the DOTNET COM library, but I saw it is disabled. I don't know how to enable it, so I tried uncommenting the following lines in my php.ini file, under the [com] section: com.typelib_file = php_com_dotnet.dll…
BourneShady
  • 955
  • 2
  • 17
  • 36
6
votes
1 answer

Has anyone compiled a rabbitmq/amqp library for php 5.2.x on windows x64

I'm trying to publish messages to RabbitMQ from a php (5.2.x) script on my windows X64 dev machine. The problem is that I didn't find any dll extension for php. My collegue is actually trying to build it (cf. How do you compile a PHP extension on…
6
votes
4 answers

PHP modules don't load after installing PHP 7 to my server

I installed PHP 7 to my server (as a result, I have not /etc/php5 and /etc/php/7.0). When I run my web app, I cant see any of my previous CURL (or fork). at first I got this err msg: Message: Call to undefined function curl_init() and after…
Imnotapotato
  • 5,308
  • 13
  • 80
  • 147
6
votes
2 answers

Zend: How to correctly destruct a custom object in PHP 7?

I'm learning PHP extension writing in order to make some old extensions work with PHP 7. I tried to modify the sample extension from http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/ but it kept causing segfaults when destructing…
Frederick Zhang
  • 3,593
  • 4
  • 32
  • 54
6
votes
4 answers

File Info PHP Error - Class 'finfo' not found but the module is in php.ini

I am having a problem getting File Info working. It is enabled in PHP.ini but when I run a php -m it is not listed. I have PHP 5.5 so it should be standard and not need the pecl. I am a newbie and confused so please be kind. php -m [PHP…
Chris
  • 195
  • 1
  • 4
  • 17
6
votes
2 answers

Win32 PHP extension development

What are first steps creating a loadable DLL module extension for PHP to create native support for my own library on Windows? Would it require re-compiling PHP on windows? What are the tools needed? I don't want to have to use exec and the command…
Olaseni
  • 7,698
  • 16
  • 44
  • 68
6
votes
3 answers

PHP extension iterate through array

I'm starting to write a PHP extension and wish to just get my head around how to loop through an array that is passed (with the intention of changing the data value by value). Preferred method would be a for loop so that I can match array1 with…
Jason
  • 607
  • 3
  • 9
  • 25
6
votes
4 answers

Installing Phalcon PHP Devtools: "ERROR: Phalcon extension isn't installed ..." though the module is installed

After some days ago I installed Phalcon PHP, I am more and more exited about it. Now I want to try the Phalcon Devtools out. I've just installed it like in the installation manual via Composer (for Linux) shown. But when I try to execute the phalcon…
automatix
  • 14,018
  • 26
  • 105
  • 230
6
votes
3 answers

How to Install ITL extension

I want to install the PHP ITL extension so I can use it. Do I need to compile this, and if so, how do I compile it? I need it to work for both Windows and Linux.
Basit
  • 16,316
  • 31
  • 93
  • 154
6
votes
3 answers

adding Imagick in xampp

I have followed the following steps in http://bytehash.appspot.com/2012/02/Installing-imagick-for-php-in-windows-under-xampp i have downloaded the dll file for imagick and added this into xampp/php/ext folder and included it as follows:…
Liam Sorsby
  • 2,912
  • 3
  • 28
  • 51
6
votes
3 answers

Trying to get imagick running on PHP 5.4.3 at Windows x64

I have Windows 7 64 bits, PHP 5.4.3 installed through WAMP 2.2 and imagick (ImageMagick-6.8.3-9-Q16-x64-dll.exe). I tried to use the php's dll of imagick from a lot of sources but all of them give this error in apache_error.log: PHP Warning: PHP…
Frederico Schardong
  • 1,946
  • 6
  • 38
  • 62
6
votes
2 answers

What is the easiest way to distribute a PHP extension written in C

I created an extension for djondb, it's a wrapper of the library which is a C++ Library, I compiled it and it's available to be downloaded from djondb site, I'm not an expert on PHP and I've been having some problems with the distribution, mainly I…
Cross
  • 1,436
  • 12
  • 20
6
votes
3 answers

phpize and php api version doesnt match

I am trying to install memcached in my mac. I have downloaded and installed it. I added it to php.ini as well. But still memcached doesnt load. I realized that the problem is with the API version mismatch of php and phpize. This is what I get when…
Subash
  • 7,098
  • 7
  • 44
  • 70
6
votes
1 answer

how to convert zval to vector for php extension?

i'm writing a php extension for my c++ library which is defined something like this: bool getPids(map pidsMap, vector ids); now, i'm writing a php wrapper for above function like this. ZEND_METHOD(myFInfo, get_pids) { …
Prod Tester
  • 253
  • 2
  • 5
  • 16