PHP needs to be hosted on a server that can parse PHP. Astro generates HTML so can be hosted anywhere that can serve HTML.
Astro needs to run on a server that can run node etc
And php can equally have its html cached.
It needs to run on your computer to generate the HTML, but you can just run npm run build then copy the contents from the dist folder to your apache server, or whether you want to host it.
At least, thats how I do it.
I haven't used PHP for about 20 years so I'm sure its changed a lot.
Do you know how you can do this in spring? Let's say I used Thymeleaf, is there a maven target I can use to walk over a database and generate every iteration of a html website?