php files won't load
# pages-help
b
I have just discovered Cloudflare Pages and i've been testing out some stuff. I uploaded some simple stuff to github and i've been trying to make it work as an website, but it just doesn't. Index.php won't load, but when i try to run a .html file with the same content it does. Looks like php doesn't work at all even though the doc says it is a supported language. Im not using Cloudflare Pages v2, everything is marked as v1. Can you guys help me out here? :))
d
Cloudflare Pages doesn't host a webserver to run your php files, you can do fully static builds (some frameworks allow php there, although I haven't personally used php in the last 6 years), or you can use Functions - which support javascript, or languages that compile to wasm
c
If it helps to clarify, the documentation with tool/software versions such as PHP is referring to the Build Process/Machine. When you push to Github, it creates a new build, and that build environment has PHP in it. At the end of the build process, it uploads your files to Cloudflare's Edge and creates the deployment. The output files have to be static (html, css, js) or you can use functions, some Javascript frameworks do support using them natively for SSR/etc, but nothing PHP wise. Functions are Workers with a bit more magic on top of them, which fundamentally run as V8 (same JS Engine chrome uses) Isolates, so a browser-like environment. You can use WASM, but the limit of 5 MB is wayy too small for PHP
d
(1MB on free tier, currently 5MB on paid, but will be bumped to 10MB soon)
but yeah running php in that is borderline impossible, unless you do a custom build and remove features
b
Hmm.. Understood. So, just to be sure, if i use js features to load php stuff from an external server would it work?
c
If you're asking client-side, as long as your output is static html/css/js, then yea it can fetch out to any external api, just CF Pages will serve the static files just like normal, like Github Pages/any other static file host. It's a somewhat common pattern to host front end on CF Pages, and have backend using php/.net/anything else, loads nice and quick You can use frameworks with Server-side rendering that work with Workers as well to fetch from an external server and render the page as well
b
Cool! Thanks for everything! You two really helped me clarify things! :))