9 ms·
Write PHP Code Within Next.js Components
- _chimmy_chonga_ 3y agoThey only ever asked themselves if they could, never if they should.
- jalino23 3y agohaha
- timack 3y agoEvery day we stray further from God's light.
- some_furry 3y agoThanks for this, I'm deploying it to production, stat
- mrspence 3y ago"Yes this actually works. Trust me I wish it wouldn't too."
- garymoon 3y agowhy?
- teaearlgraycold 3y agoI hope with enough joking around the Next.js team realizes they've made a horrible mistake. What they should have done was include a convenient RPC framework in Next - not magic code-splitting and magic RPC code-gen built specifically for people that are too lazy to write two files for code ran in completely different environments.
- mattwad 3y agoThe Next team's core use case is a serverless framework for Vercel. Anyone looking to use it as a long-running server is just a second-class citizen.
- qudat 3y agoIf you aren’t deploying to vercel for the duration of the project, use something other than next.js. It has become a vercel only product at this point.
- hollowturtle 3y agomeh not my cup of tea. Please let me know when “use gpt” will be generally available
- loloquwowndueo 3y agoGood lord. Why.
- rob 3y agoAs someone who loves PHP/Laravel/WordPress, don't tempt me. My WordPress plugin built with Next.js, integrated with Laravel, coming soon.
- 0natcer 3y agoLaravel dev here too
- JUNGLEISMASSIVE 3y ago[dead]
- CafeRacer 3y agoThis is exactly what I wanted but newer knew existed!
- rpmisms 3y agoI may actually have a practical purpose for this. Yes, I could do the same thing with a simple API, but this is way funnier.
- CSSer 3y agoI think part of what makes these recent gags so funny to me is that it illustrates how perilous mixing RSC with client code feels in practice. Worrying about teammates accidentally exposing environment variables was already bad enough. Debugging is now even more troublesome, and for what? So we can use some XML-like syntax everywhere? React serves a purpose but this doesn't feel like it. All these directives, the lookalike tree complexity, and overloading fetch just feels wrong.
- theturtletalks 3y agoI get what you’re saying, but you can use React without RSC just fine. Next.js might be pushing RSC, but using Vite and normal React is fine. Hell, even the pages directory still works in Next.js and it has no RSC.
- qudat 3y agoI would argue that unless your need SEO there is no reason to reach for Next.js or any other react framework. The default should be vite and client only. Everything else only serves corporate interests.
- theturtletalks 3y agoVery true, but React is extensively used for landing pages and e-commerce where SEO is vital. If you’re using Next for those sort of apps in your company, why not use it for the dashboard? It’s seems like the natural progression instead of running Vite on internal apps and Next on external ones.
- qudat 3y agoYea I disagree. You’ll be fighting nextjs the entire time. It’s a tool for e-commerce sites. And honestly at this point you’d be better served with Astro.
- code_biologist 3y ago
- bottlepalm 3y agoIt'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, refactoring works across client/server, all that. Of course the examples of server side code in client side function handlers are just that, examples, not the suggested way to use server actions. You can write super hacky 'bad' code in every language. Server actions are best defined in their own file of course. Not sure why it's being compared to PHP so hard as PHP is a backend only SSR framework, while Next seamlessly transfers the components/code/state to the client so you can continue re-rendering with the same framework and language client side as you used server side for SSR. PHP could never do that. The closest thing to server actions in PHP is Livewire, which was never a standard part of PHP and not unique to PHP either. Most PHP apps just use normal JS libraries for interfacing with the server.
- rpmisms 3y agoThey're really cool, and act like the best parts of PHP. I actually miss the simply powerful aspect of the paradigm.
- bottlepalm 3y agoWhat part of php? php doesnt render on the client, and most php apps except for livewire don't integrate call backs to the server.
- rpmisms 3y ago"act like" here meaning DX, not actual behavior. Magical actions within UI code.
- bottlepalm 3y agoI mean doesn’t asp, python, ruby, JavaScript, etc.. all have templating languages you can do fun things in?
- dgorges 3y ago> 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.
- NorwegianDude 3y agoI know. The Next.js part should definitely be removed first. /s
- cynicalsecurity 3y agoNo sarcasm.
- pulse7 3y agoThe JS part should be removed first. No sarcasm... :)
- moralestapia 3y agoWho would win? A literal trillion dollar ecosystem ... vs. ... le edgy joke.
- omarfarooq 3y agoAll these haters of Javascript, you'd think no one actually uses it.
- arrowsmith 3y agoJavascript is widely used for frontend development because it's the only choice, not because it's a well-designed language that developers love.
- FractalHQ 3y ago
- NorwegianDude 3y agoAny way I can remove the Next.js part? That would be perfect! Haha.
- ilrwbwrkhv 3y agoYes it's called Livewire Volt. https://livewire.laravel.com/docs/volt https://livewire.laravel.com/docs/volt
- dinkleberg 3y agoI 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.
- hyggetrold 3y agoLooks nice but what would really take it to the next level is the ability to run Java but just JNI (everybody knows that's the only useful part).
- ulrischa 3y agoNot only HTML in JS, now also PHP in it. How about also adding CSS?
- droptablemain 3y ago"Your [engineers] were so preoccupied with whether or not they could that they didn't stop to think if they should." - Ian Malcolm
- byhemechi 3y agoI am extremely tempted to write a vscode mode for this. I'll let you all know if I survive
- deleted 3y ago[deleted]
- nperez 3y agoFor those not in on the origin of the joke, Next.js introduced "server actions" which became a huge meme / debate topic on Twitter - for example, https://twitter.com/peer_rich/status/1717609270475194466 https://twitter.com/peer_rich/status/1717609270475194466 This is presumably inspired by all of the people saying Next is turning into PHP.
- swyx 3y agoNext has always been inspired by PHP. in his keynote Rauchg even spent like a moment of silence dedicated to the PHP Lambo, completely out of context. it must have been confusing to others not in on the joke but for those of us in the audience it was great
- hu3 3y agoIsn't PHP Laravel author owner of a Lambo? I wonder what the plate reads.
- joshmanders 3y agoLARAVEL
- asadm 3y agoThats the origin of the meme.
- bhavikjadav 3y agoIt reads FACADE
- hu3 3y agoYep. Found it: https://x.com/taylorotwell/status/1647011864054775808 https://x.com/taylorotwell/status/1647011864054775808
- 0natcer 3y agofor anyone interested <selfpromo>i made a video about the project where this the lambo part is featured in https://youtu.be/EGOkjmyfL6E?si=gn9LQ87gBRs9q9tL&t=60 https://youtu.be/EGOkjmyfL6E?si=gn9LQ87gBRs9q9tL&t=60 </selfpromo>
- stevebmark 3y agoMy favorite part about this debate is that this is how Rails works, but Rails is worse. You intersperse raw database calls with your template code (`user.first_name`), and your templates kick off an untrackable amount of queries, and when you start nesting templates, you've lost all hope of app optimization. RSC looks like it has some great potential. I really enjoy seeing these miss-the-point trolls that overlook existing technology issues.
- adhamsalama 3y agoI commented 'When will they add "use php"?', didn't know a madlad actually did it.
- ralmidani 3y agoIronically, these days PHP has its act together - look at Laravel - better than most of the JS ecosystem does. I don’t mind JS as a core language. Web Browser APIs are pretty awesome (with a few notable exceptions like IndexedDB). But the Node and SPA ecosystem is, speaking objectively, a dumpster fire. We parody “enterprise” software, where vendors convince large companies to invest in over-engineered garbage. Node, Express, React, Vue, etc. used to be for hipsters who wanted to cobble something together with maximum velocity and flexibility. But with them now in the big leagues, we’re seeing the same “enterprise” patterns emerge. This is not an inevitable part of “growing up”; Python/Django and Ruby/Rails have been around for two decades, powered various unicorns, and are used at old-school multinational corporations as well as tech behemoths. But they have not fallen victim to the nonsense that plagues the JS ecosystem. In fact, a lot of the JS ecosystem is now the worst of both worlds; you have over-engineered “solutions” combined with outrageous churn and zero sense of direction.
- user3939382 3y agoTo me JS proves that in the right scenario, the technical quality of the language doesn’t matter at all.
- droptablemain 3y agoCan confirm that it works with shell_exec as well.
- neontomo 3y agoTerrifying.
- thinkingkong 3y agoMoving past the excellent joke. The problem I see with Next has nothing to do with re-visiting these concepts, and almost everything to do with the examples. Flipping your mindset from “react is a framework for client side rendering” to “react is a dsl for building HTMl on the server” is a leap and it brings all this junk with it. I think thats how we get these parodies, and the “sql in a component” nonsense. What is missing though is guidance on how to clearly separate these things. How do you do permissions, security model, clear separation of concerns, etc within nextjs in this new world? This is not new ground so the patterns should be pretty easy to describe. But thats missing and as a result, we do have people saying “no no. The process.exec call was a demo” without realizing that people are going to refer to that as a best practice.
- girvo 3y ago> “react is a dsl for building HTMl on the server” Whats quite amusing to me in the context of this joke, is back in the late 2010s we actually used React this way in PHP via the V8JS PHP extension lol In production, too.
- toasted-subs 3y agoImo I liked the dev experience with next but I'd be nervous releasing it to the public
- tantaman 3y agoYou think this is a joke but Meta/Facebook has something similar for interop between XHP (https://github.com/hhvm/xhp-lib https://github.com/hhvm/xhp-lib) and React.
- leptons 3y agoDo I have to??
- aussieguy1234 3y agoAs much as I like PHP and JavaScript, as the README in this repo alludes to, this is cool concept but its not a good idea to actually use this. Some of the worst code I've had to maintain are weird mixtures of PHP/JS all in the one view file including where you have PHP generating JS/interpolating in variables. PHP as a templating language alone is actually pretty decent, but you need to keep the JavaScript separate to keep things clean.
- giancarlostoro 3y agoI'm not sure if it still has it but the Wordpress login file had some mix of JS and PHP a few years back.
- frodowtf 3y agoIt's time to stop.