Skip to content
php-baremetal REGISTRY
Publish a package

php-baremetal/ext-hello

bm-ext MIT

Demo extension: bm_hello() only, no dependencies.

needs no platform HAL

ext-hello · PHP API

PHP API

The whole PHP surface of ext-hello: one function that returns a fixed string. No arguments, no state, no side effects.

The extension registers under the module name hello and adds a single global function.

bm_hello

bm_hello(): string

Public method. Returns string.

Returns the string "hello from ext-hello package". It takes no arguments; passing any throws an ArgumentCountError.

php project-src/index.php
<?php
var_dump(bm_hello());       // string(28) "hello from ext-hello package"

Checking it is there

A firmware built without the package has no bm_hello(). Guard optional use with extension_loaded() or function_exists(), so the same script runs on both:

php guarded call
<?php
if (extension_loaded('hello')) {
    echo bm_hello(), "\n";
} else {
    echo "ext-hello is not built in\n";
}

Related