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
5
votes
4 answers

Install PHP 7.0 Internationalization extension (Intl) on XAMPP on Mac

I followed the instructions outlined here: Install PHP Internationalization extension (Intl) on XAMPP on Mac Ran sudo pecl install intl selected the correct files from the Cellar then this error…
Danny F
  • 392
  • 8
  • 21
5
votes
4 answers

Docker - How to disable PHP ext / modules

I am working on a PHP API and I would like to disable unused php Modules inside my PHP-FPM image, such as "sqlite3, pdo ..". I am a docker beginner and I would like to know if is there anything similar to docker-php-ext-enable if not what is the…
Mohamed Salem Lamiri
  • 5,767
  • 6
  • 34
  • 47
5
votes
1 answer

What is exactly a zend extension?

if you look at this documentation, the first parameter returns only Zend extensions. What is exactly a Zend extension, as compared to a PHP ("simple") extension?
Bob5421
  • 7,757
  • 14
  • 81
  • 175
5
votes
1 answer

Convert Zval to char*

I want to convert Zval to char*. how do i do that in my php extension?
Karthick
  • 2,844
  • 4
  • 34
  • 55
5
votes
2 answers

PHP GD bundled extension without recompiling PHP - solution

The bundled extension offer a lot of functionality. I have spent a lot of time how to compile extension for my version of PHP. So there are instructions.
kuba1999
  • 499
  • 1
  • 5
  • 12
5
votes
1 answer

Can't Enable PHP Extensions on php.ini on App Engine for Laravel

I'm trying to enable some php extensions needed by Laravel. The documentation for the php.ini file (https://cloud.google.com/appengine/docs/php/config/php_ini) says to place a php.ini file in the root of the application. This is what my php.ini…
Lou
  • 79
  • 1
  • 3
5
votes
1 answer

Does laravel necessarily need proc_open() and passthru() enabled?

I am installing laravel on a shared hosting at KVC webhost. It shows a blank page. I checked the log and it says that the proc_open() and passthru() aren't enabled on my server which is causing the errors. I have contacted my webhosting for…
Bharat Geleda
  • 2,692
  • 1
  • 23
  • 31
5
votes
2 answers

Logging fatal/parse errors in PHP5

I'm writing an error logging service that will be integrated into websites running on my server, that will email me error batches, etc. So I've been trying to find out if there's a way to handle fatal and parse errors, however not using the tricks…
PeterBelm
  • 798
  • 1
  • 8
  • 22
5
votes
3 answers

Your requirements could not be resolved to an installable set of packages

Sorry for duplication of this question with another one. I can't solve my problem. I am working on a project based on Ratchet. I am trying to run the Push Integration example. So, in order to run, I should use composer to get some dependencies. I…
Hossein Mobasher
  • 4,382
  • 5
  • 46
  • 73
5
votes
1 answer

Retrieve class name from a Php::Value at PHP-CPP

Working on a small extension for PHP using PHP-CPP, I receive at C++ side, an array with objects and I need retrieve the class name of it. The object Php::Value didn't looks like have any method for it. Similar as i do at HNI in this…
mcuadros
  • 4,098
  • 3
  • 37
  • 44
5
votes
2 answers

can't get PHP extensions to load on OS X Mavericks

So I upgraded to OS X 10.9 Mavericks and I'm trying to set up my local dev environment again. I ran xcode-select --install as mentioned in this thread which lets me compile the extensions successfully. I've confirmed that the extension exists in…
Ty W
  • 6,694
  • 4
  • 28
  • 36
5
votes
2 answers

Why does PHP fail to produce an image when loading an image that has been taken from facebook?

A couple of years ago I authored a PHP (ZEND) module that I still use today in some of my projects. This module was built with a fairly rudimentary (i.e. copypasta) understanding of PHP image manipulation but works beautiful except in one case. …
Crispen Smith
  • 513
  • 4
  • 20
5
votes
1 answer

Installation of extension in PHP

I'm trying to install extension to PHP 5.3.6 on Ubuntu 11.10. Extension is: php-protobuf from https://github.com/allegro/php-protobuf. First I compiled it: phpize, ./configure, make then finally sudo make install. I got: Installing shared…
zie1ony
  • 1,190
  • 2
  • 14
  • 33
5
votes
1 answer

How to make ZEND_BEGIN_ARG_INFO_EX control number of arguments, passed to a PHP extension?

I'm developing a PHP extension, using C. So far I'm working on the proper validation of arguments, passed to the extension's function from PHP userspace. The macro ZEND_BEGIN_ARG_INFO_EX can be used to provide Zend Engine with information about the…
Andrey Tserkus
  • 3,644
  • 17
  • 24
5
votes
1 answer

How to load two versions of the same php extension?

The web application I am working on needs to be able to handle two different versions of the same PHP extension. (Specifically MapScript for Mapserver 5.6 and MapScript for Mapserver 6.2.) The script won't know which of the two versions needs to be…
alexwells
  • 1,243
  • 13
  • 16