Add example to include/require file
I've read through the examples at Php-Wasm in Javascript and Php-Wasm in Static HTML and I haven't found an example of how to include / require / include_once / require_once another PHP file. My use-case is pretty simple. I have a PHP file with a function and I want to use it from JS. I've tried many different options but all of them failed, usually with this error:
Warning: PHP Request Startup: Failed opening 'phpShrink.php' for inclusion (include_path='.:') in php-wasm run script on line 2
Am I missing something obvious?
@vrana You should be able to include any additional PHP files under the files constructor parameter, which is available under static HTML as the data-files attribute. Once they're in the FS you should be able to include then normally.
https://php-wasm.seanmorr.is/filesystem/loading-files.html
https://php-wasm.seanmorr.is/getting-started/php-in-static-html.html
Thank you. It seems that this was simply a version problem. I've imported https://cdn.jsdelivr.net/npm/php-wasm/PhpWeb.mjs but you need to import https://cdn.jsdelivr.net/npm/[email protected]/PhpWeb.mjs. Can you please add this to https://php-wasm.seanmorr.is/filesystem/loading-files.html?
Anyone else facing this issue and want it to run offline, You can see simple code here in the repo
https://github.com/coolb0y/php-inbrowser/tree/php-browser