TypeApp: Minimalist Native PHP Framework for IoT Backend Development

TypeApp is a minimalist PHP framework built on TypePHP's native compilation technology, providing a component-based architecture with 15+ standardized components for IoT backend development, featuring full ahead-of-time compilation, MQTT broker, IoT center, and multi-database support, enabling high-performance native executables for edge deployment.

Open Source Tech Hub
Open Source Tech Hub
Open Source Tech Hub
TypeApp: Minimalist Native PHP Framework for IoT Backend Development

Core Concepts: TypePHP vs TypeApp

TypePHP is the underlying full-compilation tool that compiles PHP code into native executables for target platforms, solving performance and interpretation overhead. TypeApp is the complete server-side framework and standard application template built on TypePHP, providing standardized architecture layers, component system, and IoT-specific capabilities. Together they form a closed loop from business code to native program.

The design philosophy is eight characters: minimalist build, native run . No heavy all-in-one bundling, no redundant mandatory conventions; clear componentization and layering organize business logic, letting developers focus on business while gaining native compilation performance.

Architecture Design: Three Layers

01 / COMPILE - Full Compilation

Unlike typical code packaging, TypeApp's full compilation feeds framework kernel + business code + production dependencies together into the TypePHP compilation pipeline. The entire program chain undergoes unified compilation optimization with no runtime interpretation layer, yielding fast startup and low memory footprint — ideal for IoT edge nodes and lightweight service deployment. Static configuration, route declarations, model mappings, and transaction definitions are generated as explicit code at build time rather than dynamically parsed at runtime, further reducing runtime overhead.

02 / COMPOSE - On-Demand Composition

The framework itself is lightweight yet capable. It provides 15+ standardized components — HTTP service, ORM database, MQTT messaging, build tools — all following the type-xxxx naming convention and installed via Composer on demand. Use only what you need, avoiding bloat while ensuring projects of any scale find matching capability components.

03 / DEVELOP - Business Focus

Development retains the familiar classic layering: Controller + Service + Model with clear responsibility boundaries. Developers need not concern themselves with compilation internals; just write business logic per convention. Repetitive work — routing, configuration, data mapping — is auto-generated at build time. One business codebase spans both development debugging and native production execution.

Core Capabilities: Full-Scenario Service Coverage

Basic Service Capabilities: Standard Server-Side Stack

As a qualified server-side framework, basic capabilities are complete and compile-time optimized:

Standardized application structure : Unified controller, service, model layering conventions clarify business boundaries, lowering team collaboration and maintenance costs.

Configuration and environment separation : Clear distinction between build-time declared configuration and runtime environment data, flexible environment switching, adapted to native compilation build logic.

Annotation-based HTTP routing : Declare route paths directly via attributes; build-time auto-generates route parsing code — concise, intuitive, no manual registration.

Multi-database support : Native adaptation for MySQL, PostgreSQL, SQLite, encapsulating query building and transaction handling to meet varied project storage needs.

IoT-Specific Capabilities: Scenario-Driven Native Architecture

This is TypeApp's core differentiator from ordinary server-side frameworks — not merely plugging in an MQTT client, but embedding a complete IoT system at the architecture level.

1. IoT Center

The framework includes a full IoT management foundation: tenant management, thing model definition, device access management, data routing, control flows. It hands you a ready-made IoT business skeleton — no need to build device management, permission isolation, data routing from scratch — enabling rapid business logic development atop thing models.

2. MQTT Service

Provides a standalone composable MQTT Broker component supporting authentication, TLS encryption, persistent sessions, resource budget configuration. It can independently handle massive device message ingress, and deeply integrate with business services to close the loop: device messages trigger business logic, service commands downlink to devices — the core communication backbone for IoT scenarios.

Quick Start: Two Paths

Prerequisites

PHP version: >=8.4 && <8.6 Composer installed

PDO extensions for target database: pdo_sqlite, pdo_mysql, or pdo_pgsql Git read access to official repositories (private)

Native compilation requires matching target platform SDK; pure development debugging can skip this

Path 1: Run Official Standard Demo (Quick Experience)

Clone and enter project

git clone [email protected]:zoujingli/typeapp.git
cd typeapp

Install dependencies composer install --no-scripts --no-plugins Environment check (no DB, only verify base env and config)

composer demo --help
composer demo --check

Run database migrations (SQLite default, must explicitly run migrate to create DB file , service does not auto-create tables) composer demo:migrate --run DB file generated at build/demo/runtime/demo.sqlite.

Set token and start service (Bearer token min 32 chars; generate random for local test)

export APP_API_TOKEN="$(openssl rand -hex 32)"
composer demo:serve

Service listens on 127.0.0.1:9501. Optionally persist token in .env as APP_API_TOKEN=your_token.

Test API calls (new terminal, same token)

Health check:

curl -sS -H "Authorization: Bearer $APP_API_TOKEN" http://127.0.0.1:9501/demo

Create user: POST /users with JSON body; returns 201 with id and version (used for updates/deletes).

Query users: supports pagination, fuzzy search, filtering, sorting; default 20 per page. Example:

curl ... 'http://127.0.0.1:9501/users?page=1&age=20&sort=age&direction=DESC'

Update user: PATCH /users/{id} with version for optimistic locking; version auto-increments on success.

Delete user: DELETE /users/{id} soft delete; returns {"deleted":true}; subsequent query returns 404.

Path 2: Create Independent New Project (Custom Development)

Clone project template

git clone [email protected]:zoujingli/type-project.git my-app
cd my-app

Initialize DB config (run once before deps, choose sqlite/mysql/pgsql) php configure.php sqlite Do not re-run after deps installed and development started.

Install dependencies composer install --no-scripts --no-plugins Environment check and migrate

php dev.php help
php dev.php check
php dev.php migrate run

SQLite DB file at var/app.sqlite.

Start dev service

export APP_API_TOKEN="your_token"
php dev.php serve

Visit GET / for template entry info.

Daily dev tools

# Generate code declarations
php vendor/bin/type prepare type-app.json
# Hot reload watch changes, auto-restart service
php vendor/bin/type watch type-app.json serve

Common Errors and Troubleshooting

git clone fails : Repository is private; need read permission for the Git repo.

401 Unauthorized : Two terminals have different APP_API_TOKEN; do not regenerate random token on caller side.

404 Table not found : Did not run migrate command; service does not auto-create tables.

409 Version conflict : Optimistic lock check failed; GET latest record to fetch current version, then resubmit update.

Page blank : SPA hash routing load issue; does not affect functionality, just follow commands.

Current Status and Applicable Scenarios

As an evolving framework, TypeApp has core skeleton but is not yet an out-of-the-box complete commercial platform. Key boundaries:

Positioned as "IoT open-source framework"; core delivery is server-side framework, IoT Center, MQTT components; full platform capabilities still iterating.

Some core components (e.g., type-mqtt) remain in private development in main repo; require corresponding repo read access.

"100% full compilation" is a coverage threshold for production source code; does not guarantee all third-party PHP packages compile perfectly.

Development branch ≠ stable release; production should lock composer.lock for dependency consistency.

Cross-platform covers Linux x64/ARM64, macOS ARM64, Windows x64, but specific capabilities depend on target platform toolchain and database validation results.

In short, it suits teams with technical capability wanting to build native IoT backends on PHP stack, not a zero-code platform.

Summary

TypeApp opens a new scenario boundary for the PHP ecosystem: without switching tech stacks, gain native compilation performance and lightweight deployment, while purpose-filling IoT device management and messaging gaps.

It especially fits:

Small-to-medium IoT projects for device access, data processing, and management backend.

Teams accustomed to PHP stack pursuing native performance and lightweight deployment.

Projects needing quick setup, clear layering, and independently evolvable server-side business systems.

After basic APIs run, you can further configure MySQL/PostgreSQL, integrate IoT Center and MQTT service, execute full native compilation and deployment, gradually building a complete IoT backend system. As TypePHP compilation matures, this "native compilation + vertical scenario framework" combo may become the core direction for PHP penetration into IoT and edge computing.

More: https://iots.thinkadmin.top

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

edge computingPHPIoTbackend frameworkMQTTnative compilationTypePHPTypeApp
Open Source Tech Hub
Written by

Open Source Tech Hub

Sharing cutting-edge internet technologies and practical AI resources.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.