News for hackers. Stuff that matters.
Re:Modern PHP by yurishimo on Sunday March 27, 2022 @12:04PM (#30821311)
PHP is probably the best language for server side webdev today. Still insanely easy to deploy, lots of features at the language level, and the frameworks that are available are very sophisticated. Whether you like Laravel or not, it’s influence is spreading to other frameworks within PHP and other languages. Also, Laravel has some of the best docs in OSS, period.

I think WordPress is pushing other projects forward as well. The tech stack over there doesn’t move nearly as fast, but the UX is still pretty good out of the box and with the enterprise clients I work with on a daily basis, they all still love WP.

Back to PHP proper for a minute, the language is fast. There are efforts being made to run PHP on Serverless infrastructure or with continuous process environments. New features are added to the language on a regular basis as evidenced by this post and others. The defacto package manager, Composer, is also world class.

It’s a good time to be a PHP dev!

As a final point, I’ll throw out some of my worries. I’ve been writing PHP since 2010~ as a high schooler fooling around.

The “Java-fication” of PHP is real. There is a push for more types and type related features. These aren’t bad in isolation, but as they move deeper into the core of the language, there is a risk of breaking legacy apps. Historically, backwards compatibility has been excellent and allows older apps to upgrade PHP versions and take advantage of performance improvements without a rewrite. I’m not advocating keeping 100% compatibility forever, but recent versions have played more fast and loose with breaking changes. We’ve done a decent job of carrying the entire community onto new versions and that will be important for continued adoption.

Take a look at the open RFCs for more details. I think there is value for pulling good ideas from other languages, but we don’t need every idea from every language.

Here’s to another 20 years of PHP!

Re:Modern PHP by Cyberdog on Sunday March 27, 2022 @08:30PM (#30825630)
> I think WordPress is pushing other projects forward as well.

If anything, it's holding PHP back. I don't often work with WordPress projects, but when I have to, it makes me want to cry with how backwards they are. WordPress doesn't even have a real routing system!

Furthermore, its ecosystem just seems to encourage really, really bad things, like user-editable templates, PHP code "snippets" stored in the database, images which should be in themes stored as post attachments instead, and just general lack of respect for the idea of separating code and content. Almost every "plug-in" or template is crippled and begging for license fees and/or throwing spammy "notifications" all over the admin interface. I know this sort of stuff are more culture issues than code ones, but they're still problems, and ones you only really see happening in WordPress sites.

I get angry when a client comes to me with a bundle of WordPress mess and asks me to fix or improve something. It's shameful and disrespectful to take a client's money and give them a WordPress site in return. Do these people actually not realize there's far better things out there?

Re:Modern PHP by exodust on Sunday March 27, 2022 @10:49PM (#30826590)
> It's shameful and disrespectful to take a client's money and give them a WordPress site in return

If their site is already Wordpress and they ask you to fix it, then your job is to fix their Wordpress site. Where is the shame and disrespect in that?

I agree about the spammy notifications and PHP code snippets. But sometimes code snippets can save time. It's better to have 10 code snippets to achieve 10 fixes, than 10 plugins to address those same fixes.

There must be a lot of developers out there paying their rent and feeding the cat from Wordpress plugin subscription earnings. While this does encourage the spammy ecosystem, it also encourages competition between plugin authors to maintain and develop quality plugins that do the job.

> Do these people actually not realize there's far better things out there?

I'd be interested to hear what good replacements there are for Wordpress+WooCommerce? I find WooCommerce slows down Wordpress, regardless of caching plugins and other tricks. It's annoying, and I'm genuinely interested in alternatives with as much flexibility and support?

Re:Modern PHP by Cyberdog on Monday March 28, 2022 @03:16PM (#30834422)
> If their site is already Wordpress and they ask you to fix it, then your job is to fix their Wordpress site. Where is the shame and disrespect in that?

None. I just finished up such a contract myself earlier this month. I was speaking of building new sites from scratch.

> I agree about the spammy notifications and PHP code snippets. But sometimes code snippets can save time.

Put code in code files, under version control. Not in the database. Not in a blob field that gets eval()ed and is editable by users. This is sane web dev 101.

> I'd be interested to hear what good replacements there are for Wordpress+WooCommerce?

Drupal 7 + Drupal Commerce was very nice back in the day. I don't know the current state of Commerce under Drupal 9 but it's what I'd start looking at first if someone wanted me to build them a store from the ground up. Magento is still around, though I've heard that its code is incomprehensible. And if you're not afraid to take the thin framework or frameworkless route, the Omnipay library [1] combined with standard CRUD for the products should get you pretty far.

1: https://omnipay.thephpleague.com

Re:Modern PHP by technobabbler on Monday March 28, 2022 @12:05AM (#30827039)
Shopify?
Re:Modern PHP by troyvit on Monday March 28, 2022 @12:26AM (#30827147)
Insofar as there is an overlap between the two I'd pick wordpress. Shopify has all the painful buy-in that comes with a bloated sass with too much market share coupled with a marketplace that is just as toxic as that of wordpress. At least with WordPress you can control your deployment.
Re:Modern PHP by exodust on Monday March 28, 2022 @04:12AM (#30828316)
Yep, I almost added "not Shopify" when asking for alternative woocommerce suggestions, but thought that was a given! I did indeed mean alternatives where deployment is controlled. Wordpress+Woocommerce does actually tick along okay, like an old bus it blows a bit of smoke and eventually gets the user to the checkout.
Re:Modern PHP by icedchai on Sunday March 27, 2022 @10:50PM (#30826596)
I do PHP work on the side and won’t touch Wordpress. It’s just plain awful.
Re:Modern PHP by cies on Sunday March 27, 2022 @05:13PM (#30824206)
> PHP is probably the best language for server side webdev today.

What are your credentials with non-PHP, non-JS/TS languages? Have you written some Rust, Kotlin, Swift, ReasonML/ReScript/OCaml, Haskell, Elm or Clojure? Those languages are different to some extend, they take fresh approaches, they contain new ideas and are scrape throat well designed.

I find most cheering for PHP and JS have very little exposure to other camps of software development.

> PHP is probably the best language for server side webdev today.

I'm telling you (opinion ahead), it most likely is not. And most likely will never be. It simply has too many fundamental design errors that have long known solutions, are near impossible to fix in PHP/JS and are fixed-by-design in other languages that also have good tooling for web-dev.

This is not just PHP/JS. But since we are looking at "the best lang for webdev" I limit myself the these and this use case.

Re:Modern PHP by ipaddr on Sunday March 27, 2022 @06:49PM (#30824939)
I have and to suggest replacing php/js with haskell as the best server side tool in general is signs that someone may be living in a bubble.

I understand you have invested time in other languages, we all have but lets focus on facts not fears of your choice of language seeming less popular.

Re:Modern PHP by cies on Sunday March 27, 2022 @08:00PM (#30825431)
> I have and to suggest replacing php/js with haskell as the best server side tool in general is signs that someone may be living in a bubble.

Please read my comment again. I'm not saying Haskell is the best lang for webdev. I'm just saying that claiming "PHP is probably the best language for server side webdev today" is missing a lot of innovation that is very usable for webdev, and hint at bubble think.

The "best language for server side webdev today" is going to be a matter of taste either way. But when one's saying it is PHP, I immediately wonder what other languages the person has done webdev in: since PHP is not a very nice language IMHO.

> I understand you have invested time in other languages, we all have but lets focus on facts not fears of your choice of language seeming less popular.

So what are the facts that make PHP the best for webdev? I dont think it is often picked for greenfield project by highly skilled teams, when given the choice to pick any language they like. And that would be a fact I'd respect in this context.

Re:Modern PHP by ipaddr on Sunday March 27, 2022 @08:53PM (#30825793)
Php has been around for 20+ years which means the pool of experienced developers is much larger than other ecosystems with new languages. Greenfield php projects by experienced developers are created everyday.

When someone brings up haskell as a best choice for server side web development as a replacement for php it makes me think this person is either very new or trying virtual signal that they are smarter and more skilled because they use a more difficult powerful language. That's like saying building a laser from a kit to cut your bread is better than using a knife. Nevermind the cost, time, safety, availability of parts and employee market for each skill would clearly point to a knife as the best tool. Very few companies still in business build a laser when they need a knife.

Re:Modern PHP by theamk on Sunday March 27, 2022 @09:36PM (#30826095)
The idea is that there are different things that different languages offer, and you need to know "what's out there" before you can claim that one language is the best.

For example, if you never programmed in any of statically-typed languages, you cannot say if they are better or worse. Similar things go for OOP-oriented stuff, or immutable-by-default languages or languages with well-designed stdlib, etc...

You may still think that PHP is the best language after trying a few other, wildly different ones, and that's fine. But unfortunately, in my experience, a lot of people who really advertise PHP (and some other languages like Pascal), haven't really tried the alternatives.

Re:Modern PHP by jjeaff on Monday March 28, 2022 @12:52AM (#30827261)
Can you list off some successful web dev projects using Haskell right now?
Re:Modern PHP by cies on Monday March 28, 2022 @04:26AM (#30828414)
Hasura, JanRain, tools made by Oblomov, Silk (discontinued), Wagon.
Re:Modern PHP by theonething on Sunday March 27, 2022 @10:46PM (#30826563)
> When someone brings up haskell as a best choice for server side web development as a replacement for php

Who is saying that? I've read through this thread and I have not read anything to that effect.

Re:Modern PHP by cies on Monday March 28, 2022 @04:27AM (#30828425)
he's strawmanning me with this... I called him out, but he still keeps going.
Re:Modern PHP by makeitdouble on Sunday March 27, 2022 @10:24PM (#30826415)
When discussing server side web dev, I think the most important aspect is the ecosystem and libraries/frameworks available as much as the language itself.

> Rust, Kotlin, Swift, ReasonML/ReScript/OCaml, Haskell, Elm or Clojure?

OCaml is an excellent language depending on what you are intending to do. I can't imagine though that it would be a pleasant generic server side.

From a very quick search, it looks like to even connect to Postgres you'd have to manage yourself the connection pools ? https://medium.com/@bobbypriambodo/interfacing-ocaml-and-pos...

The same would apply to most languages on your list, except perhaps Clojure who has an excellent ecosystem thanks to the JVM. But then, is Clojure a good webdev language ? maybe ? I only toyed with it for a very short time, but I don't see it on par with PHP or ruby for instance.

Re:Modern PHP by cies on Monday March 28, 2022 @04:32AM (#30828467)
Re:Modern PHP by midrus on Monday March 28, 2022 @05:20AM (#30828729)
In my opinion, what makes a "language" the best for webdev is not its syntax. It is the ecosystem, the libraries, the amount of people that know it, the learning curve, the editor plugins available, the frameworks, etc.

Ocaml? Elm? Clojure? Haskell?. That's fun for side projects, not for real business.

Re:Modern PHP by mmcnl on Sunday March 27, 2022 @06:01PM (#30824606)
Why do you treat PHP and JS as similar languages? They're worlds apart, have different purposes and have almost nothing in common.
Re:Modern PHP by cies on Sunday March 27, 2022 @06:42PM (#30824888)
> Why do you treat PHP and JS as similar languages? They're worlds apart, have different purposes and have almost nothing in common.

Because (1) both very often used in webdev, (2) both have many "adherents" that totally love the language yet have little exposure to languages of different paradigms, (3) are (opinion alert) not very well designed.

I'm aware of the differences between JS and PHP.

Re:Modern PHP by nkozyra on Sunday March 27, 2022 @08:51PM (#30825780)
A fairly useful addendum to your list might be 4) both have grown up into completely ok languages.

If you, like me and many others, shrugged them both of for years and came back to them pleasantly surprised, it might change the timbre when reading that.

I'm not sure I agree that it's the best but it's got some things going for it:

- incredibly fast to deploy and iterate

- supported in some fashion on more hosting solutions than other languages or compiled binaries

- one of the best performing interpreted languages

Not all of these benefits apply to me so I don't use PHP but under the right circumstances I'd look at it again.

Re:Modern PHP by cies on Monday March 28, 2022 @04:37AM (#30828505)
> 4) both have grown up into completely ok languages.

Counter examples:

https://www.reddit.com/r/lolphp/ (this language is soooo weird there is a community documenting its weirdness)

https://www.destroyallsoftware.com/talks/wat (lovely talk about JS's weirdness)

I dont like the fundamental weirdness of these langs. I like predicatble langs. Unpredictable langs will never be "completely ok languages" to me.

Re:Modern PHP by nkozyra on Monday March 28, 2022 @07:57AM (#30829523)
Find me a language without a few of those classic 'wat' quirks. They almost all have them.

PHP was quite fairly maligned for a long time. The issue was never "weirdness" but rather poor design. Starting with final 5.x they started turning it around and deprecating or fixing a lot of the worst bits.

JavaScript was a joke but modern js is tight, clean and generally very fast.

Re:Modern PHP by cies on Monday March 28, 2022 @10:28AM (#30830844)
> The issue was never "weirdness" but rather poor design.

To me all weirdness IS poor design.

> JavaScript was a joke but modern js is tight, clean and generally very fast.

Fast it sure is, for an interpreted language.

On "clean and tight" I beg to differ. I find it an unholy mess: the language, the stdlib and the ecosystem.

Re:Modern PHP by nkozyra on Monday March 28, 2022 @05:47PM (#30836031)
> To me all weirdness IS poor design.

Weirdness is subjective. If you look at lisp for the first time coming from other languages it will be weird.

PHP had glaring issues for years, but they started to clean up the language around 7.x.

JavaScript was effectively a toy but grew up in a hurry when Node pushed ecmascript forward and into a well paced release pattern.

Re:Modern PHP by ajxs on Sunday March 27, 2022 @10:10PM (#30826322)
They have so much in common. They're far more similar than they are different. Both are procedural, object-oriented, loosely-typed. Their syntaxes are both loosely-derived from C. The similarities go on.
Re:Modern PHP by makeitdouble on Sunday March 27, 2022 @10:29PM (#30826449)
> object-oriented

JS isn't per se. You can use it for OOP, but it's only a subset of what you can do with it (I'd argue there is enough traps that it's better used with other paradigms than OOP). I also don't see ES6 as very related to C syntax anymore.

To your point, PHP and JS could be close in spirit, pushing forward the good parts while letting the bad parts rot on the side, and heavily relying on programmers' discipline to build clean code. Good PHP devs tend to be good JS devs as well.

Re:Modern PHP by user3939382 on Sunday March 27, 2022 @08:34PM (#30825656)
Your response is a perfect example of why these discussions are so difficult. What makes a language “good” depends heavily on your priorities and perspective.

I love Clojure, it’s so well designed. Haskell is hard to beat in terms of academic type correctness. But what if I’m trying to build a web app and my priorities were, ease of hiring and productivity, especially for junior devs, and a big ecosystem. Does Clojure win here against PHP? That’s a much harder argument to make. Would anyone say Rust is a better web development language than PHP?

All these tools have trade-offs. PHP is a fantastic choice for web development, the rough edges are becoming increasingly minimal with each successive version.

Re:Modern PHP by cultofmetatron on Monday March 28, 2022 @12:19AM (#30827109)
while there is certainly merit to choosing a language with a large talant pool. It drives me nuts how so many employers optimize for hiring juniors. Hiring a Junior is like getting a puppy and now you're picking a language that minimizes the scale of their messes.

I'd rather hire someone that knows what they are doing and give them tools to maximize the scale of their strengths.

2 good devs working in elixir, rails or clojure will accomplish far more than 10 juniors working in javascript or go.

Re:Modern PHP by cies on Monday March 28, 2022 @04:34AM (#30828478)
I much rather let juniors work on my Elm app than have on my JS app.

Strong typing helps me trust code is of certain quality.

Re:Modern PHP by yurishimo on Monday March 28, 2022 @12:16AM (#30827096)
I’ve personally tried projects in Ruby, Elixir, and node. PHP has been the best experience for me across both dev and production. Elixir has an excellent local environment story though!
Re:Modern PHP by datalopers on Sunday March 27, 2022 @11:10PM (#30826715)
> Have you written some Rust, Kotlin, Swift, ReasonML/ReScript/OCaml, Haskell, Elm or Clojure?

Nah, I like to get shit done and make buckets of money.

Re:Modern PHP by unfocussed_mike on Sunday March 27, 2022 @12:11PM (#30821384)
> The defacto package manager, Composer, is also world class.

Composer suddenly got good, didn't it! Composer 1.x was one of my pain points I think.

I can't think of many things that really bug me much anymore.

Null coalescing operators and named parameters are the kinds of things that make me happy.

I also adore Laravel (and particularly Lighthouse).

But what I really like about PHP is the humility and maturity of the whole endeavour. It's really typified by Rasmus Lerdorf who openly critiques his own abilities and seeks out smart people.

Re:Modern PHP by esistgut on Sunday March 27, 2022 @06:11PM (#30824670)
Lighthouse is an hidden gem. I moved some projects from Node/Typescript to Laravel/Lighthouse after discovering it.
Re:Modern PHP by tmpz22 on Sunday March 27, 2022 @12:12PM (#30821394)
There is so much variety in web development that to crown any language as “the best” is at best unproductive.

This attitude of “what is the best” promotes cargo culting and should stop.

Re:Modern PHP by unfocussed_mike on Sunday March 27, 2022 @12:29PM (#30821541)
> This attitude of “what is the best” promotes cargo culting and should stop.

The terse certainty in your response is ironic, is it not?

Considering the parent post frames that as opinion with the word "probably" and then makes a case for the opinion.

Re:Modern PHP by pc86 on Sunday March 27, 2022 @05:16PM (#30824240)
The truth is whatever one's personal list of "must haves" and "should haves" are for a given language, there are probably at least 2 or 3 major languages that fit the bill in a given domain, and probably more if you're willing to use stuff like Haskell or Racket or Clojure (all fine languages but compare their popularity to JS or PHP to Python).

For every person who is vehemently in favor of one language over all others, it's usually pretty easy to point out another language that will get you 99% of what that other language will. So it's not a very tenable position to think one language is the be all end all.

But on the flip side, and in part because of the points above, "language cargo culting is stupid and should be avoided in almost every instance" can make a great deal of sense.

Re:Modern PHP by chockchocschoir on Sunday March 27, 2022 @12:32PM (#30821563)
> There are efforts being made to run PHP on Serverless infrastructure

This is very interesting, I didn't know this. This is a perfect fit for PHP, as it was always designed with this model in mind, and the programmers that use PHP are already used to this way of developing, as that's exactly how php-fpm and mod_php already work and always have.

Re:Modern PHP by throw_m239339 on Sunday March 27, 2022 @12:47PM (#30821698)
> This is very interesting, I didn't know this. This is a perfect fit for PHP, as it was always designed with this model in mind, and the programmers that use PHP are already used to this way of developing, as that's exactly how php-fpm and mod_php already work and always have.

Yes, but now you have to pay for every requests made to your app instead of just paying $4 a month for a shared Apache server and I also have to architecture my PHP app in a rigid way to fit whatever "serverless" execution model the SAAS runs with.

Re:Modern PHP by francislavoie on Sunday March 27, 2022 @12:51PM (#30821737)
Which may be much cheaper than $4/month if you have very low traffic numbers.
Re:Modern PHP by throw_m239339 on Sunday March 27, 2022 @12:58PM (#30821797)
> Which may be much cheaper than $4/month if you have very low traffic numbers.

A big IF. My $4/month stay $4/month without the added complexity of "serverless" deployment nor every stupid constraints this business model imposes. If serverless actually didn't make money, this business model wouldn't exist or wouldn't be pushed, mainly by Amazon employees here.

Re:Modern PHP by jjeaff on Sunday March 27, 2022 @03:00PM (#30822995)
It's php, so your architecture by nature is already serverless unless you are using some newer plugin like swoole.

For most projects, that $4 server is great and what I would prefer. But where serverless can excel is an application that has very spikey usage.

If your $4 server gets hit with spikes of usage that would require a $500 server for an hour once or twice a month, you might be better off with serverless, rather than paying $500/month to have a server that big all the time.

Re:Modern PHP by ipaddr on Sunday March 27, 2022 @07:03PM (#30825056)
The traffic costs of a $500 server vs the price of ondemand pricing for an hour or two would still be in favour of the $500 dollar server.
Re:Modern PHP by bliteben on Tuesday March 29, 2022 @11:59AM (#30844263)
why are we even talking about a $500 php server, that is like the 0.01% of websites, You either need really specialized requirements or to be in the top 1,000 websites to need anything near what you can get for $500/month.
Re:Modern PHP by jjeaff on Thursday March 31, 2022 @07:25PM (#30873421)
That was an arbitrary number, but I don't think that is true. It doesn't take much functionality before you will start needing the power of a server in the $500 range. Many apps today do a lot more than serve up static requests. I run a php server with just a few thousand daily active users and we need a $250/mo server.

You have your app, and database, and then your logging, tracing, and tracking stack and It all starts adding up pretty quickly.

Re:Modern PHP by ipaddr on Sunday March 27, 2022 @06:59PM (#30825026)
A fixed cost of $4 dollars that can host hundreds of websites or a variable pricing model where any traffic level would end up costing you more with no ceiling.

Choosing serverless would be a bad game theory strategy choice.

Re:Modern PHP by francislavoie on Sunday March 27, 2022 @12:42PM (#30821657)
For example: https://bref.sh/
Re:Modern PHP by dgb23 on Sunday March 27, 2022 @01:59PM (#30822402)
> Historically, backwards compatibility has been excellent and allows older apps to upgrade PHP versions and take advantage of performance improvements without a rewrite.

This has not been my experience at all. Updating PHP versions _and_ some even fundamental libraries has been very painful and anxiety inducing, you had to be very careful and patient. It's similar to JS in that regard and in some cases worse.

Re:Modern PHP by sdoering on Sunday March 27, 2022 @03:52PM (#30823453)
Just anecdata. My SO is currently working for a very small regional dairy producer (think 18 people total). Naturally they have a website no one really knows how to handle. My SO needed to update stuff, received the login info and the first thing we saw was WordPress stating that php5.6 is too old and should be updated.

After some arguing with the company that is payed to manage their IT environment she got them to finally update the php version and now the server is running 8.1.

I was glad that at least wp was up to date. Current wp running on quite old php version and exactly nothing broke with the update.

I was positively surprised. Would have expected more problems from my experience with other projects in other languages.

Re:Modern PHP by yurishimo on Monday March 28, 2022 @12:21AM (#30827118)
The WordPress core team does a great job of updating to support new PHP versions as soon as betas are released. Hell, in the most recent version, they even patched in some of the new PHP8.1 functions so they can be used before the official release.

We all know the tech is out of date at its core, but I don’t think it’s fair when people say they’re holding PHP back when there is an active effort to keep things compatible.

Re:Modern PHP by francislavoie on Monday March 28, 2022 @02:08AM (#30827591)
It's holding PHP back in the sense that because there's so many WordPress installations out there running on old versions of PHP and old versions of WordPress, that _will_ have to update at some point, it means that PHP internal devs need to always consider how any breaking change they make would affect those users.

In general, the WordPress community is _slow_ and plugin authors and users definitely do not keep up at the same pace at the rest of the community using more modern frameworks. They tend to have written worse code in general, which are proportionately more impacted by deprecations and error promotions where the code wasn't using best practices.

The PHP internals maintainers hear complaints from people in the WordPress space saying "whoa you're making too many breaking changes too fast, I can't keep up", meanwhile having the developers of modern frameworks getting impatient, wanting all the new features to save them time in writing new code.

If PHP didn't have all these legacy projects still in use, deprecations/strictness changes could move at a faster pace.

Re:Modern PHP by mjrpes on Sunday March 27, 2022 @02:58PM (#30822985)
Are you tracking warnings/deprecations in logs? Usually PHP gives ample warning time (at least one major version) before producing errors.
Re:Modern PHP by dgb23 on Sunday March 27, 2022 @03:27PM (#30823235)
I tracked the warnings and I keep up with changes out of necessity. But that's the least they can do - anything else would be insanity. However it does not make me feel any better when debugging version/compatibility/configuration issues between the language, different libraries and the environment.

I'm not saying there aren't good reasons for _some_ of the changes, including historical error prone baggage. I'm also not in any way try to disrespect the maintainers. But to say PHP is a stable language and ecosystem still does not reflect my experience with it.

Re:Modern PHP by ceejayoz on Sunday March 27, 2022 @03:24PM (#30823198)
A good test suite does wonders, too.
Re:Modern PHP by dgb23 on Sunday March 27, 2022 @03:32PM (#30823296)
The tests are there to give us confidence about _our_ code. They can help in those situations, but they don't protect us from others pulling the rug from under us.
Re:Modern PHP by pc86 on Sunday March 27, 2022 @05:18PM (#30824253)
Unless you're upgrading production before lower environments, you'll still find out exactly what you need to fix, won't you? And unless you're waiting until the last possible moment to upgrade core infrastructure I don't see how anyone is getting any rug pulled out from anywhere.
Re:Modern PHP by dgb23 on Monday March 28, 2022 @03:43AM (#30828143)
Again, seeing what will be broken is the baseline expectation. My comment is not about that. It’s about breaking changes, having to resolve them, facing incompatible versions (language, libs, tooling).

You telling me you broke my code in advance doesn’t make it OK.

Re:Modern PHP by dehrmann on Sunday March 27, 2022 @01:29PM (#30822104)
Something I pick on with PHP is because requests are so isolated, it doesn't have a good story for pooling SQL and HTTP connections. Its model really limits you when it comes to sharing resources between requests.
Re:Modern PHP by francislavoie on Sunday March 27, 2022 @01:42PM (#30822241)
It's possible to have persistent MySQL connections, but there's all kinds of caveats; MySQL connections are stateful, so bad things can happen, and the performance benefits are only very slight. https://www.php.net/manual/en/features.persistent-connection...
Re:Modern PHP by Nilithus on Sunday March 27, 2022 @11:18PM (#30826775)
This is indeed a downside but there are workarounds -- The wikimedia foundation put out a good blog post talking about getting HTTP connection pooling for PHP

https://techblog.wikimedia.org/2020/10/26/impact-of-using-ht...

TLDR they used envoy proxy as a sidecar container. So to your point its a pain but still achievable

Re:Modern PHP by peter422 on Sunday March 27, 2022 @12:11PM (#30821391)
What does a modern high performance php serving stack look like?
Re:Modern PHP by supz_k on Sunday March 27, 2022 @01:17PM (#30821967)
We handle 50-60 million monthly page views (comments embed requests) in our commenting system using PHP/Laravel, NGINX (2 load balanced servers), Redis (for queues and caching), and MYSQL.

All performance issues we have ever encountered were always related to the database - never had an issue with PHP or Laravel.

However, we use Node.js for websockets. Though there are some improvements in PHP for event-driven development (like ReactPHP [1]), it was quite hard to find proper documentation and help to build a production-ready WebSocket server. So, we ended up using Node.js for that.

The new features added to PHP in the latest versions are great. Type hinting and return types are really helpful in writing better code. I hope there will be an addition to type hint advanced data structures (ex: Arrays of Objects) in a future version.

[1] https://reactphp.org/

Re:Modern PHP by nine_k on Sunday March 27, 2022 @08:28PM (#30825619)
If you want better types, have you taken a look at Hack?

https://hacklang.org

Re:Modern PHP by donatj on Sunday March 27, 2022 @01:46PM (#30822274)
We handle a couple million daily users, educational online reading product used by K12 schools worldwide.

Internal framework PHP monolith, nginx, Aurora MySQL, redis, Memcache, internally developed message queue, handful of small Go microservices.

While we're largely hosted on AWS, some countries require us not to be, namely China, where are product lives on servers run by the government. We've kept are infrastructure non-AWS compatible.

For our US installation, monolith scales up to 50+ servers during the day and down to a minimum of 2 at night.

Re:Modern PHP by charrondev on Sunday March 27, 2022 @02:13PM (#30822545)
At $WORK we serve billions of requests a month on with nginx, php-fpm, and Percona.

In total I think it’s something on the order of ~1000 application servers (nginx/PHP) that are specced to handle 28 concurrents, and 200 Percona instances of varying sizes. A big HAProxy cluster sits in front of the whole thing and cloud flare in front of that.

A whole bunch of memcached servers spread around too. By far the biggest bottleneck is the MySQL servers at the moment, so we rely heavily on memcached to keep requests away from the DBs.

Re:Modern PHP by jjeaff on Sunday March 27, 2022 @03:57PM (#30823504)
Just curious, have you calculated what it would cost to have the equivalent of those 50 servers as dedicated bare metal servers?
Re:Modern PHP by donatj on Sunday March 27, 2022 @07:54PM (#30825376)
I haven't. That's all Ops, and I'm a developer. We're a pretty small team of about 15, and managing physical servers would require a big investment in staff alone.
Re:Modern PHP by jjeaff on Thursday March 31, 2022 @07:21PM (#30873386)
There is little difference in managing a bare metal server vs an AWS VM. Both can come preinstalled with your OS of choice. And you are responsible for maintaining the system either way. I'm not talking about colocating your own hardware in a data center. Just renting bare metal.
Re:Modern PHP by hu3 on Sunday March 27, 2022 @12:32PM (#30821562)
Not OP but I have seen web apps with 1 million MAU (Monthly Active Users) using:

- Laravel

- Redis

- PostgreSQL

- Nginx+ php_fpm

Re:Modern PHP by unfocussed_mike on Sunday March 27, 2022 @12:44PM (#30821678)
I am deploying considerably smaller applications but I've had good results lately with Caddy and PHP-FPM [0]. I tend to use MySQL 8 but I've made use of both Redis and Memcached where appropriate.

I don't even use any of the JIT stuff, but I will soon.

[0] Once I figured out how to configure Caddy, that is. (Laravel vs Caddy documentation ease of use is night-and-day territory.)

Re:Modern PHP by francislavoie on Sunday March 27, 2022 @12:53PM (#30821760)
FWIW, a Caddy config for a Laravel app is just the following (which you can find here in the docs https://caddyserver.com/docs/caddyfile/patterns#php):

    example.com {
        root * /srv/public
        encode gzip
        php_fastcgi localhost:9000
        file_server
    }
Do you have any specific comments regarding Caddy's docs? What exactly did you find difficult? I'm a Caddy maintainer, and I'm always looking to find ways we can improve.
Re:Modern PHP by unfocussed_mike on Sunday March 27, 2022 @01:16PM (#30821960)
(Thank you for your reply! I'm using some of that pattern. It wasn't enough for my requirements, unfortunately. What I have now works fine; I use the handle directive a fair bit and that makes sense to me. This is not a problem now)

The main problem with Caddy's documentation is that it is a maze of twisty tunnels! Lots of terse fragments of documentation that bounce you on to other terse fragments of documentation. It feels fractured and impermanent. I lose my place.

Part of the problem is inherent to very flexible packages like this, and it is going to be difficult to solve.

I think you possibly overestimate how many people have time to learn about the JSON syntax or API configuration, how many people want Caddy outside of a package manager installation, etc.

It almost seems to me that you need entire documentation guides -- "Caddy for Nginx users", "Caddy for Apache users", "Caddy for people who need an API-driven server" -- that have much more narrative flow to them.

(IMO, configuration file adapters are a hiding to nothing. Just explain to me why Caddy is better and help me make the switch)

I love Caddy for what it is now doing for me -- please don't get me wrong, I think it's an impressive project -- but after 28 years of configuring web servers I really need migration documentation that I can read in detail without clicking from link to link and lots of emoji people.

Small observation: the mid-blue text on a pale blue background for your code examples and monospaced text is difficult to read if your eyes are over 40 years old and it's been a long day.

Re:Modern PHP by mholt on Sunday March 27, 2022 @01:22PM (#30822028)
This is valuable feedback, thank you. A lot of people just say that the docs suck and we can't do anything about that. This is more helpful. I'll see what we can do to improve cohesiveness and clarity/accessibility.
Re:Modern PHP by InvaderFizz on Monday March 28, 2022 @12:21AM (#30827119)
FWIW, I'm very comfortable with nginx, but preferred something with Acme built in.

What I struggled with most in setting up things with caddy was the context for a config statement.

I could usually find the config parameters I needed, but I had no idea at what level of nesting it was and in what context it was used.

I would have found it incredibly useful to have a reference caddyfile for every parameter so I could see it used in context and then just strip that reference file down to what I need and go from there.

In the end, I just went back to nginx and dealt with Let's Encrypt myself since that was what I was most comfortable with and decided learning this new thing wasn't worth the benefit at that moment for the specific project. I'll probably revisit it later this year.

Re:Modern PHP by mholt on Monday March 28, 2022 @01:13AM (#30827341)
Did this page help? https://caddyserver.com/docs/caddyfile/concepts - it explains the structure of the Caddyfile, what directives are, and goes from there.
Re:Modern PHP by unfocussed_mike on Sunday March 27, 2022 @01:31PM (#30822122)
Thanks -- I'm glad it didn't come across too whiny, because to be honest you've saved me from so much HTTPS pain so far I really will put up with a _lot_! :-)
Re:Modern PHP by francislavoie on Sunday March 27, 2022 @01:39PM (#30822208)
Thanks! I appreciate that feedback.

I do want to work on improving the "Tutorials" section to make it apply to more installation methods (i.e. running in Docker requires additional setup to use the admin API, running as a service means you may need to turn off the service before playing with the tutorial, etc)

"Caddy for X users" pages are complicated to get right IMO, and I'm not sure it's worth the effort - those are also general purpose servers, and can be used an infinite amount of different ways. Comparing them is difficult and I'd argue that it's not that useful. Take for example https://statamic.com/vs/wordpress to get a sense of what I mean.

> I think you possibly overestimate how many people have time to learn about the JSON syntax or API configuration

I definitely don't; I spend a lot of my time improving and polishing the Caddyfile adapter since it's definitely the easiest way to use Caddy. The tutorials do put too strong a focus on JSON in my opinion (Matt wrote them). But on the other hand I think it's pretty important to understand that the Caddyfile _is_ an adapter to JSON and not the native config language. It's key to knowing how to debug and inspect how Caddy actually runs.

> how many people want Caddy outside of a package manager installation

I'm not sure I understand this point though, what are you trying to say here? You can definitely just download the caddy binary and run it wherever, you don't need to use a package manager. I'm not sure what this is trying to point to.

Re:Modern PHP by unfocussed_mike on Sunday March 27, 2022 @02:06PM (#30822474)
> The tutorials do put too strong a focus on JSON in my opinion (Matt wrote them).

I don't mean to start a fight between friends! :-)

> But on the other hand I think it's pretty important to understand that the Caddyfile _is_ an adapter to JSON and not the native config language. It's key to knowing how to debug and inspect how Caddy actually runs.

Agreed.

> I'm not sure I understand this point though, what are you trying to say here? You can definitely just download the caddy binary and run it wherever, you don't need to use a package manager. I'm not sure what this is trying to point to.

Sorry, I mangled that with a run-on sentence, didn't I! What I mean is, I think more users are likely to want the package manager, systemd-configuration deal. The automatic-HTTPS thing is such a strong sell that I think a lot of people will seek to replace nginx just for that.

I could totally be wrong here but this is where I think a sort of narrative document for Nginx users at least is perhaps worth it.

Some of this is always going to be a challenge because Caddy is a fascinating, category-straddling project; you've made a product that is somewhere between a magical automatic appliance, a Golang web dev framework and a traditional configurable server, that avoids the downsides of all of those things as far as is really possible.

Documenting that is definitely a unique challenge.

I'm prattling on now but thank you again for Caddy; it really is a great contribution.

Re:Modern PHP by francislavoie on Sunday March 27, 2022 @02:14PM (#30822555)
> I don't mean to start a fight between friends! :-)

Nah it's fine ^_^ we both know we have a difference of opinion there, and we balance eachother out on that.

> Sorry, I mangled that with a run-on sentence, didn't I!

Hah, maybe a bit! Thanks for clarifying, that helps. We'll definitely take those comments into consideration when we work on updates to the docs!

Thanks for the kind words <3

Re:Modern PHP by PetahNZ on Sunday March 27, 2022 @10:17PM (#30826373)
We use AWS elastic beanstalk mostly, so just auto scaling EC2 servers running nginx, RDS serverless, SQS worker queues etc. Front end is static hosted on S3/cloud front. Handles up to ~100k orders per day.
Re:Modern PHP by hermanradtke on Sunday March 27, 2022 @04:42PM (#30823906)
I spent a decade writing PHP. I think the language is fine, but the lack of a real concurrency model (event loop or threads) pushed me to other languages for web dev.
Re:Modern PHP by gremlinsinc on Sunday March 27, 2022 @05:32PM (#30824362)
Swoole a php extension has solved this mostly, and has coroutines like golang.
Re:Modern PHP by PetahNZ on Sunday March 27, 2022 @10:02PM (#30826274)
Anything that can be run concurrently, we just push off onto worker queues.