Getting started
From an empty machine to a blinking board: install the tools once, then create, build and flash a project.
Once per machine
-
Step 1: Install phpbm and the conductor
composer global require php-baremetal/phpbm php-baremetal/conductor. Composer asks to allow the conductor plugin: answer yes, or runcomposer global config allow-plugins.php-baremetal/conductor true. To use the PHAR instead ofphp-baremetal/phpbm, see the install section of the overview. -
Step 2: Install an SDK
phpbm sdk:install esp32downloads the newestesp32SDK release, checks its sha256 and unpacks it into~/.phpbm/sdks/esp32/<version>.
A new project
phpbm init asks for the SDK, the board, the runtime and the storage, offering only the runtimes and storages
the board can run. It prints the next commands, including a composer require for any package the chosen
runtime needs (event-driven needs php-baremetal/ext-events). composer require runs the conductor, which
writes .phpbm/manifest.json: every other phpbm command reads it.
The toolchain step needs a project because it installs the toolchain of the project's SDK. It is a one-time download (about 6 GB for ESP-IDF) shared by every project on the machine.
Write the program
The firmware runs project-src/index.php. With the init-loop runtime the script runs once, then setup()
and loop($tick) repeatedly:
gpio_mode() and gpio_write() come from ext-gpio, delay() from ext-sys
(composer require php-baremetal/ext-sys). Check the API of each extension on its registry page. After editing, run phpbm flash again: phpbm rebuilds
what changed and flashes.
When something is off
phpbm discoverlists the serial ports, the chip on each one and the boards of the SDK that use that chip.phpbm build --cleanrebuilds from scratch.- Every error names the command that fixes it; Troubleshooting collects the common ones.