Documentation
About
InstanceIO is a PHP component framework for static websites and dynamic applications. Build reusable UI components from PHP classes, HTML templates, and CSS, then add HTMx, Docker, APIs, and flat-file export when your project needs them. This frontend comes HTMx-ready as well as Docker-ready out of the box. The framework also has the ability to export to flat-file HTML ready for S3/serverless functions or IPFS.
Install
To install the IIO package into the vendor directory, ensure you are in the application root directory and then run the following command:
php install.php
This assumes you have the IIO package installed in a directory one-level above the application root directory: ```./../iio```. The package can be pulled from [the official IIO git repository](https://github.com/senicity/iio)
HTMx
This framework has full-HTMx support out of the box and can compile to HTML so you can upload only HTML files to your server, serverless function or bucket. This will also work dynamically with IPFS.
Docker
Iio has the ability to build a local docker environment for quick development. Run the following command in the root folder of the application:
php console/cmd.php Docker build
This assumes that you have PHP and Docker installed locally as well as the ability to run Docker locally in non-sudo mode.
Create An HTML Build
To build your website/app to flat-file HTML, run the following command in the root folder of the application:
php console/cmd.php Build
This creates a 'dist' folder in your application root which can be uploaded or sent to a server, serverless function or bucket. This assumes that you have PHP installed on your machine. This can also be run inside of the docker container as long as you are in the root of the application first.
Make A Command
You can create any new command that can be run via the built in console by running the 'Make command' command. Here is an example:
php console/cmd.php Make command <command_name>
Make A Route
You can extend the core SDK code for the web or api routes by running the 'Make route' command. Here is an example with all available options and flags:
php console/cmd.php Make route <route_type (web || api)> <controller_method> <route_path> <route_view_method> <controller_name> <make_flag>
Make A Controller
You can create any new controller that extends the core SDK code by running the 'Make controller' command. Here is an example:
php console/cmd.php Make controller <controller_name> <controller_method> <controller_view_method>
Make A Component
You can automatically create the component files but running the 'Make component' command. Here is an example:
php console/cmd.php Make component <component_name>
Routers
Web routes render complete pages. API routes use headless mode and return component fragments.
Configuration Validation
IIO validates configuration before the application starts. Runtime, Docker, and update profiles report missing keys and incorrect types through IioConfigException.
$config->get("root.resources", "resources");
$config->require("api.endpoint");
$config->validate("runtime");Nested access preserves configured false, zero, empty strings, and null values. Application-specific sections such as sites and i18n are allowed.
Safe Output
Use context-aware output helpers instead of concatenating untrusted values into markup.
$this->text($title);
$this->attr($id);
$this->url($href);
$this->raw($this->trustedHtml($trustedMarkup));Typed component placeholders include {%text:title%}, {%attr:id%}, {%url:href%}, and {%raw:content%}. Raw output requires explicit trusted markup.
Request and Site Context
IIO exposes normalized request and site context objects for host, path, query, method, locale-independent site selection, and URL generation.
$app->requestContext->path();
$app->siteContext->siteKey();
$app->siteContext->url("/about");Sites can match exact hosts or the longest configured path prefix. Static builds support preserve_prefix and strip_prefix policies.
Route Groups and Lazy Handlers
Route groups expand shared handlers across prefixes. Lazy handlers execute only after the request matches.
$this->routeGroup(["/ca", "/nl"], function () {
$this->routeLazy("/about", [$this->aboutController, "index"]);
});Existing routeBuild() declarations remain supported. Lazy handlers can return legacy response arrays or IioResponse objects.
View and Response Hooks
View post-processors transform full-page and 404 HTML. Response post-processors can change content, status, and headers after rendering.
$this->View->addPostProcessor(
fn (string $html) => str_replace("", "Ready", $html)
);
$this->addResponsePostProcessor(function (IioResponse $response) {
$response->headers["X-Framework"] = "IIO";
return $response;
});Headless responses skip view processors but still run response processors. Cached responses also pass through response processors.
Hardened Static Builds
Static builds use validated sitemap routes, a bounded loopback server, staged output, atomic promotion, ownership markers, safe asset copying, and generated asset-reference checks.
php console/cmd.php Build --mode=combined --policy=preserve_prefix
php console/cmd.php Build --mode=separate --policy=strip_prefixCombined builds keep all site prefixes in one tree. Separate builds create independent site trees. Existing unmarked output requires --force before replacement.
IPFS Deployment
IIO publishes the contents of dist/ through the native Kubo ipfs executable. The contents of dist/ become the CID root, so a combined build opens at /ipfs/<CID>/index.html, not under an extra dist/ directory.
Install Kubo, then initialize and inspect the local repository from the application root:
php console/cmd.php Ipfs setup
php console/cmd.php Ipfs statusBuild, publish, verify, and start the local gateway in one command:
php console/cmd.php Ipfs deploy --build --serveWait for Daemon is ready, keep the terminal running, and open the printed local gateway URL. Press Ctrl-C to stop the foreground daemon.
php console/cmd.php Ipfs check --cid=<CID>
php console/cmd.php Ipfs serve --cid=<CID>
http://127.0.0.1:8080/ipfs/<CID>/IIO verifies the local pin, root directory, and index before serving. Local pinning protects the local repository, but it does not guarantee that another server can retrieve the CID. Nodes behind double NAT or carrier-grade NAT may have limited inbound reachability.
Configure a remote provider such as Pinata with a token held in an environment variable:
read -s PINATA_JWT
export PINATA_JWT
php console/cmd.php Ipfs remote setup --service=pinata --endpoint=https://api.pinata.cloud/psa --token-env=PINATA_JWT
php console/cmd.php Ipfs remote pin --service=pinata --cid=<CID>
php console/cmd.php Ipfs remote status --service=pinata --cid=<CID>Pin every new build after local verification with --remote:
php console/cmd.php Ipfs deploy --build --remote --remote-service=pinata
php console/cmd.php Ipfs deploy --build --remote --remote-service=pinata --remote-backgroundThe Pinata JWT is never stored in application configuration or source code. IIO reads it from the environment and Kubo stores the configured remote service credentials in the local IPFS repository. Wait for the remote status to become pinned.
{
"ipfs": {
"binary": "ipfs",
"path": "~/.ipfs",
"gateway": "http://127.0.0.1:8080/ipfs",
"cid_version": 1,
"pin": true,
"remote": {
"service": "pinata",
"endpoint": "https://api.pinata.cloud/psa",
"token_env": "PINATA_JWT",
"name": "iio-website",
"background": false,
"deploy": true
}
}
}Use --binary=/path/to/ipfs, --ipfs-path=/path/to/repository, --gateway=https://gateway.example/ipfs, --cid-version=1, --pin=false, --no-pin, --remote-service=<name>, or --remote-background to override configuration. The old https://ipfs.io/ipfs/ gateway is retired; use the provider gateway or another active IPFS gateway. Read the full IPFS deployment guide for setup details and production considerations.
Component Providers and Composition
Components can use request-scoped lazy providers and recursively render child components with inherited context.
$controller->registerComponentProvider(
"work", fn () => new WorkRepository()
);
$work = $this->provider("work");
return $this->child("WorkFutureSection", ["current_slug" => $slug]);Providers are memoized. Composition detects cycles and enforces a maximum nesting depth. Typed attributes such as enabled:bool, count:int, and items:json are opt-in.
Route-Derived Sitemaps
Generate a versioned sitemap from registered GET web routes instead of maintaining every path by hand.
php console/cmd.php Build --sitemap=routes$manifest = $app->routeSitemap();
$app->writeRouteSitemap("sitemap.json");Headless API routes are excluded by default. Lazy routes are listed without executing their handlers.
Internationalization
IIO reads translations from nested arrays, source objects, JSON strings, or JSON files.
$app->translator->trans("home.title");
$app->translator->setLocale("fr");
$app->translator->choice("cart.items", 2);Configure i18n.source, default and fallback locales, and available locales. Use IIO_LOCALE=fr to override the locale. Interpolation supports :name, {name}, and {{name}}; plural catalogs support zero, one, and other.
Start building
Install the framework and scaffold your first component in under a minute.