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
238
votes
11 answers

How do I see the extensions loaded by PHP?

It's got to be somewhere in the phpinfo() dump, but I just don't know where. Is it supposed to be under the "Additional Modules" section? Somewhere else? I'm trying to figure out why some extensions don't appear to be loaded, but I don't even…
Bialecki
  • 30,061
  • 36
  • 87
  • 109
90
votes
8 answers

How to check which PHP extensions have been enabled/disabled in Ubuntu Linux 12.04 LTS?

I'm using Ubuntu Linux 12.04 LTS on my local machine. I've installed LAMP long ago on my machine. Now I want to enable following PHP extensions: php_zip php_xml php_gd2 For it first I want to check whether these PHP extensions are enabled or not.…
PHPLover
  • 1
  • 51
  • 158
  • 311
87
votes
6 answers

How to install all required PHP extensions for Laravel?

I need to make my Ubuntu 16.04. Is there a way using the GUI or is the simplest way to do this by using terminal? I have already installed PHP 7.1, MariaDB. I need to enable: OpenSSL PHP Extension PDO PHP Extension Mbstring PHP Extension Tokenizer…
Aipo
  • 1,805
  • 3
  • 23
  • 48
81
votes
8 answers

Docker image build with PHP zip extension shows "bundled libzip is deprecated" warning

I have a Dockerfile with a build command like this: #install some base extensions RUN apt-get install -y \ zlib1g-dev \ zip \ && docker-php-ext-install zip I get this warning from build output: WARNING: Use of bundled libzip is…
sakhunzai
  • 13,900
  • 23
  • 98
  • 159
72
votes
13 answers

Installing PHP Zip Extension in CentOS

I'm attempting to install the PHP Zip extension in CentOS. My server does not have external internet access, so I downloaded it myself from PECL: http://pecl.php.net/package/zip. I chose 1.10.2, the latest "stable" release, and transferred it to my…
Ubunfu
  • 1,083
  • 2
  • 10
  • 21
58
votes
4 answers

How to install php extension using pecl for specific php version, when several php versions installed in system?

I have installed both php5.6 and php7.0 from PPA on Ubuntu according to this manual http://lornajane.net/posts/2016/php-7-0-and-5-6-on-ubuntu But I didn't get how to install extensions using pecl for php5.6 or php7.0. For example I have already…
Oleg Abrazhaev
  • 2,751
  • 2
  • 28
  • 41
50
votes
6 answers

PDO_SQLITE driver not present.. what to do?

I see everywhere (including on the official docs) that the PDO_SQLITE driver is/should be included by default in PHP. However, when I look at my extension_directory, I see only these files: gd.so mcrypt.so mysqli.so mysql.so pdo_mysql.so …
Felipe
  • 11,557
  • 7
  • 56
  • 103
44
votes
4 answers

PHP intl extension in Docker container

I'm trying to load the intl PHP extension in my Docker container, but it doesn't seem to work. Have already tried this https://github.com/docker-library/php/issues/57 but I still get the same error message: configure: error: in…
Marcelo Noguti
  • 830
  • 1
  • 9
  • 17
36
votes
3 answers

Retrieve extension version in php

Is it possible to get extension version in php? get_loaded_extensions returns only loaded extentions names, but not versions :(
avasin
  • 9,186
  • 18
  • 80
  • 127
35
votes
6 answers

How do I install PHP intl extension on CentOS?

I know virtually nothing about installing packages. I managed to install Zend Framework 1 with yum a while back by following a very specific tutorial. Now I need the PHP intl extension and I can't figure out how to install it. I did yum list…
toxalot
  • 11,260
  • 6
  • 35
  • 58
34
votes
4 answers

Can't phpize or configure an extension in OS X 10.9 Mavericks

I am trying to build the memcached extension on OS X 10.9 Mavericks for use with the built in PHP 5.4, initially I tried pecl install memcached but that threw the following. checking for zlib location... configure: error: memcached support requires…
donatJ
  • 3,105
  • 3
  • 32
  • 51
33
votes
10 answers

Enabling PostgreSQL support in PHP on Mac OS X

I'm having a terribly difficult time getting the command "pg_connect()" to work properly on my Mac. I'm currently writing a PHP script (to be executed from console) to read a PostgreSQL database and email a report. I've gone into my php.ini file…
Jordan Scales
  • 2,687
  • 4
  • 28
  • 37
31
votes
5 answers

PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql.so'

I ran the command: php -v Output: PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql.so' (tried: /usr/lib/php/20170718/pdo_mysql.so (/usr/lib/php/20170718/pdo_mysql.so: undefined symbol: mysqlnd_allocator),…
flabbergasted
  • 441
  • 1
  • 4
  • 8
31
votes
7 answers

Memory usage of current process in C

I need to get the memory usage of the current process in C. Can someone offer a code sample of how to do this on a Linux platform? I'm aware of the cat /proc//status method of getting memory usage, but I have no idea how to capture that in…
scotts
  • 4,027
  • 3
  • 29
  • 26
29
votes
0 answers

Pre-compiling PHP files

As a learning exercise, I'm trying to save the compiled state of a PHP file in order to execute it at a later time without having to go through zend_compile_file again. The first thing I did was write an extension that hooks zend_compile_file. If…
MyUsername112358
  • 1,320
  • 14
  • 39
1
2 3
67 68