A simple PHP extension that demonstrates basic "Hello World" functionality.
-
Compile the extension:
phpize ./configure make
-
Run
% php -d extension=./modules/helloworld.so -i | grep hello helloworld helloworld support => enabled % php -d extension=./modules/helloworld.so smoke.php Hello World!
<?php
helloworld();
// Output: Hello World!
This guide is intended to help complete beginners with no knowledge or experience of C or PECL to take their first steps.
After cloning, edit hellworld.c
to change the message.
php_printf("Hello World!\n");
Next, compile to build.
phpize
./configure
make
This will create modules/helloworld.so
. Now let's give it a try!
php -d extension=./modules/helloworld.so smoke.php
When your message is displayed in the hellworld() function, you are done!🎉
Change the two strings helloworld
and HELLOWORLD
to suit your project. Change the function names too.
The world of PECL development is vast and there is a lot to learn, but if you can get past the environment building barrier, you are already one step ahead. Take on the challenge of PECL development from here onwards!
This project contains a GitHub action workflow file. Make sure the project is built successfully by ushing it; CI also installs Valgrind and checks for memory leaks.
This repository contains CmakeLists.txt, which Clion needs to understand the source code. Development using an IDE is efficient and allows for debugging, including a backtrace.
Refer to Developing a PHP extension in CLion for more information.