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
-2
votes
3 answers

Can I hide PHP extension in HTML source code

I know that we can hide PHP extensions on URL bar. Can we hide PHP extensions when the user view source code? For example, in the index.php page (on url bar it is abc.com/index) And I view the source code, the .php extension is still there (in
WebDeg Brian
  • 802
  • 1
  • 7
  • 21
-2
votes
1 answer

STAMDARD_MODULE_PROPERTIES’ undeclared while compling php extension

When I compling my own php extension, I get this while make ‘STAMDARD_MODULE_PROPERTIES’ undeclared here (not in a function) zend_module_entry example_module_entry = { …
Dr.Jian
  • 1
  • 1
-2
votes
1 answer

Composer will not work with current settings

The PHP exe file you specified did not run correctly: C:\xampp\php\php.exe The php.ini used by your command-line PHP is: C:\xampp\php\php.ini Program Output: Warning: PHP Startup: mongo: Unable to initialize module Module compiled with module…
-2
votes
1 answer

How can I build PHP Extension from PHP Code

I am looking to convert my PHP library code as a PHP extension. The full library is under a namespace. There are many PHP classes I am using under my library. Is there any tool which convert the PHP code to .so and .dll PHP extension (with the…
Code Help
  • 72
  • 1
  • 6
-2
votes
2 answers

How can I use Redis() in a PHP Unit Test?

I am using phpunit and want to use Redis() with it, but when I do something like: phpunit --verbose UnitTest.php It gives something back like: PHP Fatal error: Class 'Redis' not found in......
user645402
  • 737
  • 1
  • 16
  • 34
-2
votes
2 answers

Wamp and Php extension one click enable

Please tell me how to enable all these extension all at once. They are creating a lot of problem. I want to enable all of them by just one click. Thanks
Aki003
  • 422
  • 3
  • 13
-2
votes
2 answers

How to get rid of these warnings after installing zend core?

Really annoying! PHP Warning: PHP Startup: bcmath: Unable to initialize module Module compiled with module API=20060613, debug=0, thread-safety=0 PHP compiled with module API=20060613, debug=0, thread-safety=1 These options need to match in…
Mask
  • 33,129
  • 48
  • 101
  • 125
-2
votes
1 answer

@dl php causes error

A page of my site is stuck in these codes: if (@dl("gmp.so")) { echo '**'; $loaded = true; break; } else echo '%%'; no echo is happend. It seems the problem is because of @dl . php5-gmp is install on the server. How can I debug it…
hd.
  • 17,596
  • 46
  • 115
  • 165
-3
votes
2 answers

How to catch only the PHP extensions that are necessary for the app to work

I need to catch only these PHP extensions that are necessary for the app to work. The idea is removing all the PHP extensions that are not necessary for the app. Do you guys have any idea how can I do that? The app is on PHP 8.0.14 - Laravel 8
Mikaele
  • 65
  • 7
-3
votes
1 answer

Where is located a file keeping gcc, and make configuration on Linux Mint, path to include headers?

Suddenly, "make" has stopped working: did not generate *.so php extension; gcc has stopped working: did not find header files; Visual studio code started showing problems: headers missing. I have reinstalled: glibc, libc6-dev, build-essentials,…
Gintare Statkute
  • 677
  • 2
  • 8
  • 18
-4
votes
1 answer

failed to install php-extention with pecl on mac( error tips:fail to mkdir /usr/include/php/ext/msgpack)

No matter what php extention i install with sudo pecl install xxx, i was failed and got the following error tips: Is there anyone who had the same problem ?
Yang Zhou
  • 15
  • 5
1 2 3
67
68