PHP hello world for Cloudflare Workers
Your PHP code in index.php, running on Cloudflare Workers
This project uses babel-preset-php to convert PHP to JavaScript.
Wrangler
To generate using wrangler
wrangler generate projectname https://github.com/cloudflare/php-worker-hello-world
Further documentation for Wrangler can be found here.
babel-preset-php
cd projectname
# run once to install babel-preset-php and dependencies
npm install
# run every time you update index.php
npm run build
That will compile your code into index.js, after which you can run wrangler publish
to push it to Cloudflare.
For more information on how PHP translates to JavaScript, see the docs for babel-preset-php.