Title: PHP Filesystem
Published: July 15, 2026
Last modified: July 16, 2026

---

# PHP Filesystem

[ Back to top](https://developer.wordpress.org/playground/developers/architecture/wasm-php-filesystem/?output_format=md#wp--skip-link--target)

The PHP module has its own filesystem separate from your computer’s filesystem. 
It is provided by [Emscripten’s FS library](https://emscripten.org/docs/api_reference/Filesystem-API.html)
and the default APIs is low-level and cumbersome to use. The `PHP` JavaScript class
shipped with WordPress Playground wraps it with a more convenient higher-level API.

In general, WordPress Playground uses an in-memory virtual filesystem.

However, in Node.js, you can also mount a real directory from the host filesystem
into the PHP filesystem.

Here’s how to interact with the filesystem in WordPress Playground:

    ```javascript
    // Recursively create a /var/www directory
    php.mkdirTree('/var/www');

    console.log(php.fileExists('/var/www/file.txt'));
    // false

    php.writeFile('/var/www/file.txt', 'Hello from the filesystem!');

    console.log(php.fileExists('/var/www/file.txt'));
    // true

    console.log(php.readFile('/var/www/file.txt'));
    // "Hello from the filesystem!

    // Delete the file:
    php.unlink('/var/www/file.txt');
    ```

For more details consult the BasePHP class directly – it has some great documentation
strings.

First published

July 15, 2026

Last updated

July 16, 2026

Edit article

[ Improve it on GitHub: PHP Filesystem ](https://raw.githubusercontent.com/WordPress/wordpress-playground/trunk/packages/docs/site/docs/developers/23-architecture/05-wasm-php-filesystem.md)

Changelog

[ See list of changes: PHP Filesystem ](https://developer.wordpress.org/playground/developers/architecture/wasm-php-filesystem/?output_format=md#)

[  Previous: PHP.js JavaScript module](https://developer.wordpress.org/playground/developers/architecture/wasm-php-javascript-module/)

[  Next: Asyncify and JSPI: Stack Switching in PHP WebAssembly](https://developer.wordpress.org/playground/developers/architecture/wasm-asyncify/)