Assets Canister: include/require don't work with PHP files from assets canister
Resolved 💬 4 comments Opened Dec 2, 2025 by miadey Closed Feb 2, 2026
Problem
When using the assets canister architecture (Issue #192), PHP's include, include_once, require, and require_once statements fail for files stored in the assets canister.
Root Cause
The current implementation fetches PHP files from the assets canister at the HTTP request level:
- HTTP request arrives at backend canister
- Backend fetches the requested PHP file from assets canister
- Content is cached and passed to PHP's
eval()
However, when PHP code uses include '/other.php', PHP's internal file handling (zend_stream_fixup → open_file_for_scanning → compile_file) tries to open the file directly from the filesystem. This doesn't go through our Rust code, so it can't access:
- The assets canister
- The asset cache
Error Details
Canister Backtrace:
zend_stream_fixup
open_file_for_scanning
compile_file
compile_filename
zend_include_or_eval
ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER
Solution Options
- Hook PHP's file stream wrapper - Create a custom PHP stream wrapper that intercepts file:// operations and fetches from asset cache
- Pre-load dependent files - Before running PHP, analyze dependencies and pre-fetch all included files
- Modify wasp_vfs.c - Hook into C-level file operations to check asset cache
- Use bundled VFS - Files bundled at build time via
bundle_php_app.shwork fine with include
Workaround
For now, use the bundled VFS approach:
./scripts/bundle_php_app.sh path/to/your/php/app
bash wasp_backend/scripts/build_backend_ic.sh
dfx deploy
Files bundled into the WASM binary work correctly with include/require.
Related
- Issue #192: Move WordPress/PHP Static Assets to ICP Assets Canister
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗