Live data from Hacker News

Write PHP Code Within Next.js Components

github.com

71–80 of 107 posts

Re: Write PHP Code Within Next.js Components

#72

Any way I can remove the Next.js part? That would be perfect! Haha.

Yes it's called Livewire Volt. https://livewire.laravel.com/docs/volt

I haven’t touched php in ages but that actually looks surprisingly nice. Pretty much every language has one of live view type libraries these nowadays, but this looks quite robust.

Re: Write PHP Code Within Next.js Components

#73
post #68

Earlier quoted context omitted.

Pretty much the same as dealing with traditional API versioning. You can version the functions themselves, or put a version in they payload and return an error telling the user to refresh.

How do you version the functions? How does the server determine which function to call? Does it use the name of the function, or its source code file, or something else? If I rename the old version and call it `actionOld` while the new version is `action` will it know how to call the old one, or do I need to do the opposite (call it `actionNew`)? What if I move the old one to a different file?

You can use a v1 folder for your v1 functions. The server identifies functions by path and name of the action. Similar to a url. So like a url if you want a new one, you'd create actionNew, and if you move the location of the function it would break old versions without a redirect.

Re: Write PHP Code Within Next.js Components

#75

Earlier quoted context omitted.

What do you think is fundamentally bad about PHP exactly? It powers a large percentage of the web and does it quite well.

I installed wp with a theme a few years ago and the box was turned into a zombie file dump. Modern php is still not there.

“I installed some third-party PHP software and didn’t turn on auto-updates for that software, and then my server got hacked” is a hit on your server admin skills, not PHP.

Re: Write PHP Code Within Next.js Components

#76

Earlier quoted context omitted.

> Not sure why it's being compared to PHP probably just because PHP is now recognized widely as fundamentally bad design. Its just that many people who came late to the party never really knew why, so they think to themselves, no this is actually great "no API boilerplate, fetch, tRPC anything.. You just define a function and call it, very nice.". And so the cycle continues...

I'm still yet to see something as productive as PHP for web apps, ecommerce etc. You ask for a customised e-commerce shop with many standard features out of the box. How long will the Java or Rust engineers quote you? A year? Php? A week?

I've been working exclusively in javascript/node since 2015 and nothing in the JS ecosystem has ever felt as productive as rails or django or laravel. Maybe it's rose tinted glasses when working on those select few projects but compared to the node ecosystem I'm bashing my head against the wall updating libraries that provide no migration docs seeing alternative solutions saying "we don't support X, sorry."

It's just all so frustrating, and I'm not even refactoring old code! It's two years old and already so brittle.

I feel like you need to have extreme patience and foresight to correctly build maintainable JS apps. Libraries people recommend today will die out very quickly. It never really felt like this in python or ruby, but I could be having a selective memory.

Re: Write PHP Code Within Next.js Components

#77

Earlier quoted context omitted.

I'm still yet to see something as productive as PHP for web apps, ecommerce etc. You ask for a customised e-commerce shop with many standard features out of the box. How long will the Java or Rust engineers quote you? A year? Php? A week?

I've been working exclusively in javascript/node since 2015 and nothing in the JS ecosystem has ever felt as productive as rails or django or laravel. Maybe it's rose tinted glasses when working on those select few projects but compared to the node ecosystem I'm bashing my head against the wall updating libraries that provide no migration docs seeing alternative solutions saying "we don't support X, sorry." It's just…

Have you used Next? I’ve found it more productive than anything because I can reuse the same code, DTOs, components, rendering, etc.. across server and client. It feels like I’m building a single app instead of dealing with using one code base to build the page and another to update it on the client. No extra JS frameworks needed. Plus TypeScript/ES6 is crazy productive - destructuring, structural typing, super expressive while being type safe as well. This server action stuff has made communicating with the server as easy as calling a function. So much overhead gone.

Re: Write PHP Code Within Next.js Components

#78
post #20

> I hope I don't have to say this but: If you even in the slightest consider to use this in any application at all you are an absolute madman and and should be locked out of the internet for the rest of your life, I hope you find some other fun activity, maybe gardening or woodwork.

[deleted]

Re: Write PHP Code Within Next.js Components

#79

It's funny, but all you see here and on Twitter are cheap shot one liners, many of these people have never even used Next.js. I find server actions combined with RSC to be incredibly useful and powerful. Easily define and call a type safe function from client to server with zero overhead. No API boilerplate, fetch, tRPC anything.. You just define a function and call it, very nice. Type safety, code completion, refact…

[deleted]
Post reply on HN