ext-hello · Recipe
Check that a package is built in
Require ext-hello, flash, and read one line on the serial console: the fastest check that your project builds the packages it requires.
Before wiring hardware, make sure the package pipeline works: a package you require ends up in the firmware and its functions are callable from your script. ext-hello needs nothing else, so if it does not show up, the problem is the project setup, not a missing provider. Remove it from the project afterwards.
Goal
Print the greeting from bm_hello() on the serial console, and list the extensions the firmware actually
contains.
The steps
-
Require the package
From the project:
composer require php-baremetal/ext-hello. -
Build and flash
phpbm flash, as for any change to the project's packages. -
Run the script and open the console
Put the code below in
project-src/index.php, thenphpbm monitor.
The code
<?php
echo extension_loaded('hello') ? bm_hello() : 'ext-hello missing', "\n";
// Every extension compiled into this firmware.
echo implode(', ', get_loaded_extensions()), "\n";
function loop(int $tick): void
{
delay(1000);
}
Expected output; the extension list depends on what your project requires, and hello must be in it:
hello from ext-hello package
Core, date, ..., hello, ...Related
- Hello extension Overview
- PHP API PHP API