5 ms·
How is this different from something like PHP? I don't get it.
by user____name 1y ago
How is this different from something like PHP? I don't get it.
- shreddit 1y agoIt’s actually a lot like php, just without the php language stuff. It’s php for javascript devs?
- nchmy 1y agoThe difference, it seems to me, is that astro is a framework and, specifically, meant for server side generated static pages with a bit of dynamic elements in them. I don't think it is all that capable of doing highly dynamic SSR apps (though their server Islands might make that possible? https://docs.astro.build/en/guides/server-islands/ https://docs.astro.build/en/guides/server-islands/) And, also, "php" in your question could be ruby, go, C or anything else that runs on the server. I prefer htmx or, better yet, Datastar which are both small, backend agnostic, js libraries for making ssr html interactive to varying degrees. You could, in theory, use astro with them but probably better to just use something else.
- aembleton 1y agoPHP needs to be hosted on a server that can parse PHP. Astro generates HTML so can be hosted anywhere that can serve HTML.
- nchmy 1y agoWhat? Astro needs to run on a server that can run node etc And php can equally have its html cached.
- aembleton 1y ago> Astro needs to run on a server that can run node etc 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.
- nchmy 1y agoBut what you're describing could be done for php, or any other backend language/framework... There's nothing unique to Astro in this regard.
- aembleton 1y agoI'm not a frontend developer so I'm ignorant about this stuff so that's the first I've heard of it. 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?
- nchmy 1y agoi dont know anything about spring, thymeleaf etc... I assume google or llms could point you in the right direction. At worst, you could just literally crawl your site with http requests and cache the result. You could even do it from cloudflare workers and with the right caching headers could cache it all in cloudflare cdn.
- deleted 1y ago[deleted]
- todotask2 1y agoWith a PHP project, you have to make all the decisions yourself, which framework (Symfony, Laravel, etc.), how to structure things, whether you can use JSX-like syntax (you can’t, really), how to handle HTML escaping safely, and how to optimise images during build time. You can use Unpic in Laravel (The Unpic creator, also former Netlify employee is now on Astro team). https://unpic.pics/ https://unpic.pics/ I'm aware there's a new PHP web framework that's somewhat similar to Astro, but I can't recall the name. Astro gives you sensible defaults out of the box. It’s designed for modern web development, so things like partial hydration, automatic image optimisation, and using components from different frameworks just work.