Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Alex Bowers:
Writing a Hello World PHP 7 Extension
Aug 25, 2016 @ 17:25:47

In a recent post to his site Alex Bowers shows you the steps involved in creating a "Hello World" PHP 7 extension with some basic output functionality - basically just echoing out a message.

He jumps right into the code and shows you how to:

  • set up the directory and initial files for the extension
  • write the test case first (a simple PHP file checking if it's loaded and can be used)
  • updating the config.m4 to allow for enabling the extension
  • the code for src/hello.h to define the function

The final piece is the code in the src/hello.c - the C code to define some structure for the PHP interpreter to understand and be able to execute the PHP_FUNCTION(hello_world). Finally he shows how to make the extension to install it, add it to your php.ini file as a shared module and re-run the test.

tagged: helloworld extension tutorial example simple php7

Link: https://zando.io/writing-a-hello-world-php-7-extension/


Trending Topics: