Live data from Hacker News

PHP in 2022

stitcher.io

311–318 of 318 posts

Re: PHP in 2022

#311

Earlier quoted context omitted.

Php/Laravel/Livewire == Elixir/Phoenix/LiveView == C#/.NET/Blazor == Ruby/Rails/Hotwire/Turbo It's also slowly being integrated into JS frameworks although they're still behind as the focus has been clientside and static generation so far.

== Everything else/HTMX. Well currently HTMX is still a "low level" clientside library, but in a similar vein to Ruby/Rails/Hotwire/Turbo. Feels like BE-first dev and non-SPA/JS centric client webdev is slowly regaining ground. Exciting.

I've found Unpoly to be a nice middleground between those framework specific solutions and htmx

Re: PHP in 2022

#312
post #188

Earlier quoted context omitted.

I'm one of those web devs that tries everything under the sun, and I also happen to have worked for a lot of companies (more than a dozen already, I'm on my 40s). Laravel is such a *joy*. I've never had this feeling of using something so easy and productive. I've been recently building a side project with LiveWire and oh-my-god. I really wish I had discovered it before. From the templating system (you get components…

Laravel and Livewire is the best-kept secret ever because everybody is too busy being biased against PHP.

I like Laravel, but i don't like Livewire that much. Livewire is really neat when building simple interactive stuff, but when building larger more dynamic parts it gets pretty sluggish and the livewire component codebase starts to feel harder to maintain.

Last time I tried to use Livewire with Vue, it had some issues which caused Vue to lose reactivity. (Maybe Livewire removed the DOM where the Vue instance was rendered. There was some options that prevented livewire from replacing elements with given id/classname.) But if i remember correctly, you cant have livewire element which has vue components as child elements.

Maybe i was doing stuff wrong or the livewireVue compatibility is a bit better nowadays. Or maybe its because I'm too used to Vue.

It felt like the Laravel community jumped to the Livewire hypetrain quite fast and it feels like the livewire recommendation to use alpinejs in someparts is required. And most of the examples for alpinejs requires you to write inline code. (It is possible to split the code to own js files, but then again you are building something that gets closer to Vuejs.)

It feels weird to recommend to write scripts using inline javascript. That requires more CSP modifications for security and also the scripts wont get cached and are loaded every time the page loads. (If I'm correct.)

TL;DR Livewire is great for small features.

Re: PHP in 2022

#313
post #247
post #70

Earlier quoted context omitted.

Its concept of "one endpoint is one script" is one of its biggest killer features Is that still a thing in PHP world? I recently ended up working on a 'modern' PHP project using Laravel and it was all routers and views and models and auto-generated scaffolding code, just like Rails and Django. There was no sign left of that 'old' approach.

There's a lot of popular examples of more or less abandoning the old ways, but the old ways still work. I'm of the strong opinion that modern PHP with frameworks and auto-include and a ton of modelling is the wrong way to do it, but everyone else can do it that way, and I can still do things the old way and I can be happy. PHP has this amazingly zen model of computing. At the end of the request, everything is thrown…

You know, I kind of agree with you. When using Laravel I felt a lot of the time I was fighting against PHP rather than leveraging it. Back in the 'old' days when I was using PHP4 in the way you describe, PHP made sense as a choice compared to, say Python, for certain use cases. Today, I have a hard time coming up with an argument why using modern PHP and Laravel makes more sense than Rails or Django. Maybe we need a post-modern PHP movement focusing on bringing PHP back to its roots.

Re: PHP in 2022

#314
post #136

Earlier quoted context omitted.

the very fact that you don't have to think about memory management it means that there is something else taking care of it. Call it GC or otherwise, no PHP dev will be think about memory management at all, unless they are building some long-lived, large data processing

> no PHP dev will be think about memory management at all Not nowadays, for sure. In 2009-2010 it was still something to keep in mind, and careful array handling was common so the it wouldn't baloon hundreds of megabytes for not so large data structures. I wasn't working on big data (tm) at that time, but running database imports via ETL processes in PHP required a few optimization passes. I really can appreciate now…

i've been working with PHP for almost 20 years and to be honest i've never had to think about memory management until the last 10 years or so and only in case of long running processes (e.g. cronjobs)

Re: PHP in 2022

#315

Earlier quoted context omitted.

Laravel and Livewire is the best-kept secret ever because everybody is too busy being biased against PHP.

I like Laravel, but i don't like Livewire that much. Livewire is really neat when building simple interactive stuff, but when building larger more dynamic parts it gets pretty sluggish and the livewire component codebase starts to feel harder to maintain. Last time I tried to use Livewire with Vue, it had some issues which caused Vue to lose reactivity. (Maybe Livewire removed the DOM where the Vue instance was rende…

I think livewire works better with Alpine. Also, I think Livewire is great for interactions that require a backend request (such as posting a comment, refreshing some data, etc). If an interaction can be performed without reaching for the server, then Alpine is a better option.

In my opinion, when everything breaks down (and not saying this is your case, just what I think) is if you try to do every interaction with Livewire (thus reaching for the server when you shouldn't) or when trying to mix in SPA tools (such as Vue, React, etc...) with it. I suppose you'll end up with the worst parts of every solution.

Re: PHP in 2022

#316

Earlier quoted context omitted.

Categorically better for everything and not categorically better for everything you write ? How about for the type of task PHP is often used for? A nearly default CRUD web app w/loads of fields and tables? Rapid prototyping? How about a bunch of simple, standalone interface interactions in JS? The extra grammar won't provide much architectural or conceptual clarity in those super common coding tasks because they're a…

> Categorically better for everything and not categorically better for everything you write? For everything. As I mentioned, I started out using dynamically typed languages. I don't agree with your idea that types somehow make it harder to develop things quickly--even the throwaway things. With types I get to grips with a new API quickly via autodiscoverability, and types provide guard-rails to know I'm using the API…

Of course, you and I both can assemble thousands of tasks for which types are better suited. They would probably comprise the overwhelming majority of a random sampling of everyday coding tasks for professional developers. Having an opinion about what works best for you certainly isn't dogma— but deciding that your perspective is better for everyone else, too, regardless of the person, their needs, and the circumstances, is unambiguously dogmatic.

Many coders will never touch the complexity of most full-time developers' simplest code, and they deserve tools that meet their needs, too. How much future burden will explicit type declaration relieve for an indy self-taught web designer taking strings and floats from a database through an ORM and putting them into a for loop for a web-based coffee shop menu hosted on WordPress? I'd say none. Considering that WordPress runs 37% of websites and 62% of CMSs, I'd argue that there's plenty of room for blunt instruments to do blunt work. Insisting people jump through the types hoop for posterity is not reasonable.

As a long-time developer turned designer, I'm confident that using a "pack" layout strategy in many GUI libraries will consistently produce worse results than properly assembling a quick grid layout. I have my collaborators avoid it because using it == guaranteed re-write... but there's a lot of selection bias there. If teams involve someone like me, that probably means usability is paramount. As crucial as usability is, sometimes speed, convenience, and not needing barely-related expertise is more important. A developer making a dialog on a small internal utility should probably use pack even if I wouldn't. I have the patterns, organization, and syntax in my head to pull simple grid-based layouts faster than they will use 'pack.' For them, it's a bit of mental overhead for an already irritating task with no real payoff. Saying that languages shouldn't even make pack available to developers would be plainly unreasonable.

Even in the tasks you cited— I was a developer in a large library with a ton of older electronic assets. I processed significant amounts of CSV and other messy text files in many dozens of projects using everything from C, shell scripts, and Perl in the earlier days to Python, Elixir, and JS in the latter. I can count how often difficult-to-pin-down data type ambiguity burned me using zero fingers. I guarantee you having to futz around with types rather than throwing in an instance check or the like would have reduced my efficiency. If I had finicky or complex or relational data that needed to maintain integrity through a nontrivial pipeline, then I wouldn't think twice about implementing them.

In general, asserting that your way of doing something is universally better than other common ways of doing something is almost guaranteed to be dogmatic. For it not to be, you must provide a universally applicable truth that trumps individual use cases and people's preferences. "It avoids entire categories of bugs, near their source" doesn't work for people who will likely never encounter those categories of bugs. Insisting others are wrong for not agreeing with the accepted best practices of people who do regular professional dev work is absolutely dogmatic.

Re: PHP in 2022

#317
post #16

Earlier quoted context omitted.

In the past I built a few things on Google App Engine. Honestly one of my greatest regrets in life. I ported a few to PHP so I won't get screwed again when I need to change hosting provider. Still need to port some and am dreading doing it but it will be for the better.

Huh. I deploy a lot of stuff to GAE and love it. But my approach is to just write regular Django apps, add a half dozen lines of GAE-specific stuff to the settings and that's it. No trouble at all running the same apps somewhere else with only trivial changes. That's worked really well for me for work where we're already on GCP and GAE lets us run our lower traffic services reliably for very little money.

I was using Datastore and other GAE specific stuff.

Re: PHP in 2022

#318
post #313
post #247

Earlier quoted context omitted.

There's a lot of popular examples of more or less abandoning the old ways, but the old ways still work. I'm of the strong opinion that modern PHP with frameworks and auto-include and a ton of modelling is the wrong way to do it, but everyone else can do it that way, and I can still do things the old way and I can be happy. PHP has this amazingly zen model of computing. At the end of the request, everything is thrown…

You know, I kind of agree with you. When using Laravel I felt a lot of the time I was fighting against PHP rather than leveraging it. Back in the 'old' days when I was using PHP4 in the way you describe, PHP made sense as a choice compared to, say Python, for certain use cases. Today, I have a hard time coming up with an argument why using modern PHP and Laravel makes more sense than Rails or Django. Maybe we need a…

> Today, I have a hard time coming up with an argument why using modern PHP and Laravel makes more sense than Rails or Django. Maybe we need a post-modern PHP movement focusing on bringing PHP back to its roots.

Over Django: - Because if not doing SPAs, it provides infinitely better tools for the frontend, such as an integrated assets pipeline, a good template language with componetisation support - Because it is faster - Because during development every change is not a restart - Because it has an integrated queue system - Because you have popular frontend solutions such as Livewire

The only better thing I've found in Django is the admin.

Over Rails: - Because it is faster - Because PHP is far, far, far more popular tan Ruby - Because it has integrated authentication - Because it is easier to hire for

just some reasons from the top of my mind. I don't have a ton of experience with Rails and I think it is still great, but IMHO Laravel is better. I have worked with Django for about 10 years, and other than the Admin, I don't miss anything when working with Laravel. Language wise PHP vs Python is just syntax, I don't care as both ecosystems are pretty healthy.

Post reply on HN