php-baremetal / spec
Shared model of the php-baremetal build manifest and the SDK driver contract.
Requires
- php: >=8.4
Requires (Dev)
- phpunit/phpunit: ^11.0
Suggests
- phpunit/phpunit: Required by Testing\DriverConformanceTestCase
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-19 14:03:42 UTC
README
php-baremetal/spec is the contract between the tools and the SDKs of php-baremetal: a PHP library, published on
Packagist, that defines the build manifest of a project and the
interface an SDK driver implements. conductor writes the
manifest with it, phpbm reads it and loads SDKs with it, and an SDK such as esp32-sdk implements its driver
against it. It has no runtime dependency beyond PHP 8.4.
You need it directly only when you write a tool that reads a manifest, or an SDK driver for another platform.
composer require php-baremetal/spec
Manifest
PhpBaremetal\Spec\Manifest\Manifest is .phpbm/manifest.json (Manifest::PATH), schema Manifest::SCHEMA (1):
Project:name,sdk(aSdkRequirement,<name>@<constraint>),board,runtime,storage,php(a version such as8.5.11,phpMinor()gives8.5),src,entry,env,boardOverridesandoptions.Project::fromComposer()builds it fromextra.baremetalandconfig.platform.php.Package:name,type(alwaysbm-*),version,pathandmeta(the package'sextra.baremetal).kind()returns the type withoutbm-.Manifest::fromFile(),fromArray(),toJson(),ofKind('ext'),has($name).ManifestValidator::validate()returns a list of problems: extensions without amoduleor sharing one, abm-halfor another platform than the SDK's, abm-php-extthat carries more thanphp-ext.
SDK
An SDK is a directory (sdk.json, chips/, boards/, runtimes/, storages/, php/<minor>/extensions/*.json,
sources/) plus a driver class.
-
Sdk\SdkLoader::load($dir)reads the directory into anSdkand checks it: boards against their chip, extension modules and entry symbols for clashes, extension requirements for cycles. The descriptor classes are inSdk\Descriptor(SdkDescriptor,Chip,Board,Module,Option,PhpExtension,PhpRelease,Requirements,SourceArchive). -
Sdk\Driveris the interface an SDK driver implements,Driver::CONTRACTbeing the contract version (1) thatsdk.jsonmust declare:Method Meaning toolchain()A Toolchain:status(),install(),env().build($plan, $out)Build the firmware from a BuildPlan; returnsArtifacts.flash($artifacts, $plan, $port, $out)Write the images to the board on a Port.sync($plan, $port, $out)Copy the project sources to a storage the firmware does not carry; falsefor the others.monitor($port)Open the serial console; returns the exit code. identify($port)A ChipInfo, ornullwhen the chip does not belong to this platform.ports()The serial ports found. The driver is constructed with a
Context(SDK directory, toolchain directory, aProcessto run commands), and reports progress through anOutput. -
Sdk::driver($context)loads the driver class named insdk.json(driver.class, autoloaded fromdriver.autoload), refusing a contract version it does not support.
Testing an SDK
Testing\DriverConformanceTestCase (needs PHPUnit) is a base class: extend it, return the SDK directory from
sdkDir(), and it checks the contract version, that the driver implements Driver, and that toolchain(),
ports() and identify() behave. Testing\FakeProcess and Testing\BufferedOutput stand in for the process runner
and the output.
License
MIT.