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
7
votes
6 answers

How to install LDAP in Docker php-fpm alpine

any idea how can i install the php Ldap extension in dockerfile FROM php:7.2-fpm-alpine i tried the following RUN docker-php-ext-configure ldap --prefix=/usr/local/php --with-ldap=/usr/lib/i386-linux-gnu RUN docker-php-ext-install ldap but when i…
Kareem Essawy
  • 565
  • 1
  • 4
  • 14
7
votes
2 answers

sudo: pecl7.2-sp: command not found

I need to install GeoIP on PHP 7.2 . For this I am using following commands - sudo apt-get -y install gcc make autoconf libc-dev pkg-config sudo apt-get -y install libgeoip-dev sudo pecl7.2-sp install geoip-beta Top two commands are run…
Rahul Gaikwad
  • 563
  • 4
  • 9
  • 26
7
votes
4 answers

How do I enable the intl extension in CakePHP?

I am using CakePHP 3 and MAMP Pro server for my project. When I am trying to bake the cake, this error shows up: Fatal error: You must enable the intl extension to use CakePHP. I have even included intl.so and extension=php_intl.dll in my php.ini…
Srinidhi Karnati
  • 71
  • 1
  • 1
  • 3
7
votes
8 answers

PHP module is already loaded warning

Just noticed, that PHP throws warnings, when executed on the CLI: php module is already loaded $ php -v PHP Warning: Module 'PDO' already loaded in Unknown on line 0 PHP Warning: Module 'calendar' already loaded in Unknown on line 0 PHP Warning: …
automatix
  • 14,018
  • 26
  • 105
  • 230
7
votes
5 answers

Convert a class to an extension

I have a PHP class I want to convert to a PHP extension. I checked some tutorials (tuxradar's writing extensions, php.net's extending php, and zend's extension writing) and it's a bit complicated. I found the article "How to write PHP extensions"…
Wiika
  • 724
  • 1
  • 11
  • 17
7
votes
1 answer

Add .so as php extension

I have a .so file generated with SWIG. I would like use the functions defined there as a php extension. How do I add them as a php extension? I added the .so to the extensions directory, and in php.ini added a line: "extension=example.so", then…
OliverGainess
  • 163
  • 1
  • 8
7
votes
3 answers

Why does PHP refuse to enable cURL on Windows

I am using PHP 5.5.25 with Apache 2.4 on Windows 7 x64 and I am unable to activate the cURL module. I have looked around and tried all I could think of. Please assist: In php.ini, the line extension=php_curl.dll is active and the file php_curl.dll…
BeetleJuice
  • 39,516
  • 19
  • 105
  • 165
7
votes
2 answers

Phpize under Windows

I'm trying to follow the instructions here: https://code.google.com/p/php-sweph/wiki/build to compile a PHP extension. My OS is Windows XP. I'm unable to find "phpize" to do the command. However, I've installed Pear for PHP. is it something only for…
user2078745
  • 81
  • 1
  • 1
  • 3
7
votes
4 answers

PHP extensions not loading in phpinfo

So I'm running MAMP on Mountain Lion and I've installed gmagick and imagick using pecl, both are relase candidates (mainly because gmagick doesn't have a stable release and imagick 3.0.0 doesn't install, it gives a make error). The modules appear…
Vidi
  • 183
  • 1
  • 1
  • 9
7
votes
1 answer

PHP 5.3+ enable_dl not enabling dl()?

I am trying to install a 3rd party PHP extension (.so) into PHP 5.3.6-13 on Ubuntu 11.10 and use it in a web environment. The vendor's documentation suggests using the dl() function to dynamically load the library. When I try their example code, I…
jonathanm
  • 170
  • 1
  • 3
  • 8
6
votes
1 answer

How to install php-xml extension in windows?

I'm trying to install laravel-excel on my laravel project. That library requires below php extensions to be enabled. PHP extension php_zip PHP extension php_xml PHP extension php_gd2 PHP extension php_iconv PHP extension php_simplexml PHP extension…
6
votes
3 answers

PHP Warning: Unable to load dynamic library

Ok I have PHP working on my mac os x Apache 2 server. Problem I am having is it can't seem to find the extensions that allow me to connect to an sqlite database. extension = php_sqlite.dll extension = php_pdo_sqlite.dll extension =…
StuStirling
  • 15,601
  • 23
  • 93
  • 150
6
votes
5 answers

How to install php-mongo on CentOS 5.3?

I've already installed mongoDB on my VPS. It works well. Now I want to install php driver to make php work with mongoDB. I followed Mongo Installation but cannot find information I need. This manual contains only this notice: If you are using CentOS…
user342960
  • 317
  • 2
  • 4
  • 11
6
votes
3 answers

Unable to load dynamic library 'php_libsodium'

I'm trying to install the libsodium php extension (https://pecl.php.net/package/libsodium/1.0.6/windows). When I run php -m, libsodium shows up in the list. However, when I go to phpinfo, it is not listed. I also noticed that apache is giving me…
ChrCar627
  • 63
  • 1
  • 1
  • 3
6
votes
2 answers

install ncurses extensions on php7.0

I try install ncurses extensions for php7.0 but I get this error /bin/bash /tmp/pear/download/ncurses-1.0.2/libtool --mode=compile cc -I. -I/tmp/pear/download/ncurses-1.0.2 -DPHP_ATOM_INC -I/tmp/pear/download/ncurses-1.0.2/include…
Naumov
  • 1,167
  • 9
  • 22