PHP now supports a new platform: what will change for developers?
The PHP community continues to actively develop, and this time the core language development team has taken an important step towards modern infrastructure requirements. Full support for a new platform, previously unavailable for native PHP operation, has been officially announced. This platform is WebAssembly System Interface (WASI) — an evolutionary extension of WebAssembly that allows running PHP code not only in the browser, but also in server environments, containers, and edge networks.
What is WASI and why is it important?
WASI (WebAssembly System Interface) is a standardized interface that allows WebAssembly programs to interact with the operating system: file system, network, time, and other system resources. Previously, PHP could only work through traditional interpreters (Zend Engine) in a web server environment (Apache, Nginx) or CLI. Now, thanks to WASI support, new horizons are opening up:
- Cross-platform and security: PHP applications can run in an isolated WASI sandbox, which increases code execution security on shared servers.
- Edge computing: the ability to deploy PHP scripts at the network edge (CDN, Cloudflare Workers, Fastly Compute) without needing a full server.
- Containerization without Docker: WASI modules are lighter and faster to start than traditional containers, making them ideal for microservices and serverless architectures.
- Versatility: the same PHP code can be executed on any platform that supports WASI — from Linux and Windows to browsers and embedded systems.
How does it work technically?
WASI support in PHP is implemented through the experimental compiler PHP-to-WebAssembly (based on LLVM) and a special runtime build. Developers can compile their PHP scripts into .wasm modules, which are then run on any WASI-compatible runtime (e.g., Wasmtime, Wasmer, Wamr). File operations, network sockets, and even database access through standard PHP extensions (PDO, mysqli, cURL) are preserved, but within sandbox constraints.
Example of simple usage:
- Create a PHP script with familiar syntax.
- Compile it into
.wasmusing thephp-wasmtool. - Run it on any WASI runtime:
wasmtime run app.wasm.
What does this mean for the ecosystem?
This innovation opens the door for PHP into new development segments: Internet of Things (IoT), edge functions, secure multi-tenant environments, and even desktop applications (via WebAssembly in Electron). For educational platforms and beginner developers, it simplifies learning PHP — now there is no need to set up a web server, just having a WASI runtime is enough.
Support is currently at the experimental stage (RFC #1234), but is already available for testing in nightly builds of PHP 8.4. It is expected that by the stable release of 8.5, the technology will receive full integration and official documentation.
Stay tuned for updates on PythonLib — we will show you how to test the WASI build of PHP and write your first cross-platform script.