| eyebrow | SDK · Overview | |||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| lede | Code completion, signatures and documentation for the SDK classes and functions in PhpStorm and VS Code, with nothing to configure. | |||||||||||||||||
| see_also |
|
|||||||||||||||||
| prev |
|
|||||||||||||||||
| next |
|
The classes and functions of the SDK (Baremetal\Wifi, gpio_write(), store_set(), the display and sensor
drivers) live in the firmware, not in PHP files. Without help an IDE would mark them as undefined. Every
php-baremetal package that has a PHP API therefore ships its declarations, and the conductor puts them in your
project at every composer install and composer update.
Open the project folder in PhpStorm or in VS Code with Intelephense. The IDE indexes vendor/, finds the
declarations and gives you completion, parameter hints, types and the documentation of each function and class.
You do not add a plugin, a library path or a setting.
After an install the project has:
vendor/php-baremetal/ide-stubs/
README.md
ext-display.php
ext-events.php
ext-wifi.php
imu-qmi8658.php
…
There is one <package>.php per installed package that declares a stub, plus a README.md. Each file holds only
declarations with empty bodies and the documentation of the package, with the exact signatures of the extension.
The conductor rebuilds the whole folder each time, so a package you remove or update never leaves an old file
behind. A package that declares a stub which is missing is reported as a warning by composer install.
The folder is generated: do not edit it, it is overwritten. If a function or class is wrong in the IDE, the stub of the package that owns it is the place to fix, and the next install brings the fix.
If the folder is missing after the first composer install of a project, an older conductor installed globally ran
instead of the one in the project (Composer runs the global plugin of the same name). Run
composer global update php-baremetal/conductor, or simply composer install a second time.
The board's pin names are not in a package: phpbm (0.4.2 or later) writes them to .phpbm/ide/board.php at phpbm init, at
phpbm board and at each build, from the pins of the project's board. The
file declares final class Baremetal\Board\Pin with one constant per pin (an empty class when the board has no
pins) and, with the board-constants option set to global, the same
names as global constants. It is regenerated every time: do not edit it.
The .phpbm/ folder of a project holds the manifest, the build files and the IDE file that phpbm generates.
Exclude the build and cache folders from the IDE index, .phpbm/build/ above all (in PhpStorm, mark them as
excluded), but keep .phpbm/ide/ indexed: it holds board.php, the declarations of Baremetal\Board\Pin.
Excluding the whole .phpbm/ folder hides the pin names from the IDE.
The stubs are for the IDE only. They are not listed in the autoloader and phpbm does not put them in the firmware:
do not require them from your code, because every class would be declared a second time on the board. The
declarations are never executed.