-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run on Cloudflare Workers #69
Comments
+1, I'd love this to happen! |
I got PHP.wasm working in the local The bad news: I couldn't deploy it because of the 5MB size limitation – Edit: I got it down to 4.4MB! src/index.js: import { PHP } from './web/index-213897b2.js';
import wasm from './web/php_7_3.wasm';
const phpPromise = PHP.load('7.3', {
emscriptenOptions: {
instantiateWasm(info, receive) {
phpError = JSON.stringify(Object.keys(info.a));
let instance;
try {
instance = new WebAssembly.Instance(wasm, info)
} catch (e) {
phpError = e + 'thrown!';
throw e;
}
phpError = instance+'';
receive(instance)
return instance.exports
},
}
}).then(loaded => {
phpError = 'loaded in theory';
php = loaded;
}).catch(e => {
phpError = e;
});
let php;
let phpError;
export default {
async fetch() {
if (php) {
const r = await php.run({
code: `<?php echo "Hello World from PHP!"; ?>`
})
return new Response(
r.text
);
} else {
return new Response(
phpError+'',
{
status: 500
}
);
}
}
} wrangler.toml: name = "playground-worker"
main = "src/index.js"
node_compat = true
compatibility_date = "2020-04-04" src/web/php_7_3.js: export const dependenciesTotalSize = 4428017;
-import dependencyFilename from './php_7_3.wasm';
+const dependencyFilename = './php_7_3.wasm'; |
Running WordPress on CloudFlare is not viable yet. Loading PHP alone exceeds CloudFlare 128MB memory limit by a tiny margin, and that doesn't even include loading WordPress files. This issue is blocked until either PHP.wasm can run with much less memory or CloudFlare doubles the memory limit. Longer version below: I managed to deploy PHP into CloudFlare and now am running into this error when the worker was starting:
Then I've built PHP with a different set of options and the worker started, but the first request resulted in this error:
CloudFlare platform limits for paid users are, as of today:
Measuring the memory required by the node.js build tells me it requires roughly 132MB – very narrow margin:
I've tried building PHP with the following options:
But that didn't help. |
Here's a bit more info:
According to However, maybe it's somehow off by one digit. Mac process monitor says |
Seems the max size for a worker is now 10MB, so that bit’s solved. Memory limit still seems to be 128MB though. |
|
Nice! |
Perhaps wasmCloud is a more reasonable place to start with this? |
This might be far out there, but here goes...
Since WordPress is working with WebAssembly and SQLite based on this project, how about expanding the scope from testing to production with Cloudflare Workers + CloudFlare D1 (SQLite database)?
Related issues
The text was updated successfully, but these errors were encountered: