Live data from Hacker News

PHP – The Right Way

phptherightway.com

101–110 of 349 posts

Re: PHP – The Right Way

#101
post #94
post #88

Earlier quoted context omitted.

Why do you presume this is "hearsay PHP hatred"? I (not parent) have PHP hatred. It is fuelled by decades of PHP development and -exposure. My hatred is based on failing projects, missed deadlines, burnouts, money stolen, severe downtime, and companies going bankrupt. PHP had a role (not the primary, mind you!) in all of them.

It had a role because PHP is the most used web technology in the world.

Not only that, I can almost guarantee that computers were involved in all of those failing projects as well, yet are not receiving any blame for it. Neither does the chairs. Damn chairs always avoiding blame.

Re: PHP – The Right Way

#102
post #80
post #48

Earlier quoted context omitted.

What tools? What server language today except PHP (and its forks) is actually designed for the web and works as the web was intended?

What server language today except PHP (and its forks) is actually designed for the web and works as the web was intended? The implication of the question is that there's something designed into PHP that makes it better for working with web things. Why does the language need to be designed to work with the web? That part of any language can be filled out with a framework quite easily, and arguably that means it's much…

Continuing on Rails: It's suprising how little Rails does with the web. Rack is the layer handling the HTTP stuff. Which then sends its requests to ActionDispatch, which calls the correct ActionRouter.

IMHO this is still too much HTTP, as I'd prefer to keep the entire HTTP out of my app, but after your routers, there's nothing "Web": it could all be "domain specific".

Ruby, the language, is, indeed, hardly "Web" at all. Ruby stdlib has some HTTP stuff but that is both lacking and optional.

Re: PHP – The Right Way

#103
The reason why people now care about PHP is that, decades ago they thought PHP would the right way to develop projects, now they are stuck, because they cannot get rid of PHP any more. If you look at any well grounded projects, they try to avoid PHP at all cost. Only handful amount people are responsible for core development. Decision are made based on "copying" other languages like Java, plus you always end up using lots of tools just to make your code safer.

There are tons of tools to get things done, PHP is one of the worst ones.

Re: PHP – The Right Way

#104
post #34

I totally expected it to be a troll site. It's actually sensible advice. But, really, I suggest using other tools. We have nicer tools now.

As someone who had to learn a bit of PHP recently, I really don't see why would anyone pick it up these days other than vendor/business lock in. Laravel is great but there are hundreds of equally as great frameworks on dozens of more moderns and better though out languages: go, python, nim, ruby etc. A bunch of useful functions expanded into the default namespace is no longer that special.

Re: PHP – The Right Way

#105
post #78
post #40

Earlier quoted context omitted.

Java solved this by using domain names as unique identifiers. I can use com.banffy and be sure only a complete a*hole would make a package in this space.

This is roughly PHP’s approach. In this case, Illuminate is the vendor prefix and Mail is the package name. This often but not always corresponds to the rules around the composer package name, which would be illuminate/mail in this case. This is similar to NPM’s organisation prefix (@foo/bar). But yeah, I’m not defending the hacky way namespaces are resolved through autoloading. I do prefer actual language support fo…

I actually prefer auto-loading, which lets you iterate through a package manager much easier/faster - PHP iterated through PSR-0[0] before landing on PSR-4[1], and you can always build your own (which is what most frameworks pre-composer were doing).

With Rails 7 and Zeitwerk, the Ruby community has landed on a very similar auto-loading system as PHP now[2] with constants translating to paths by convention.

[0]: https://github.com/php-fig/fig-standards/blob/master/accepte...

[1]: https://www.php-fig.org/psr/psr-4/

[2]: https://github.com/fxn/zeitwerk#the-idea-file-paths-match-co...

Re: PHP – The Right Way

#106

Actually, that make me remember statements of Linus Torvalds on Git at Google Tech Talk Conference: But I did end up using CVS for seven years at a commercial company and I hated it with a passion. When I say I hate CVS with a passion, I have to also say that if there are any SVN users in Subversion, users in the audience, you might want to leave because my hatred of CVS has meant that I see Subversion as being the m…

There are a plethora of articles for "foo best practices" or "bar done right".

I feel like you are stretching a quote to fit a premise that doesn't match the context of this thread or article.

Re: PHP – The Right Way

#107
post #80

Earlier quoted context omitted.

What server language today except PHP (and its forks) is actually designed for the web and works as the web was intended? The implication of the question is that there's something designed into PHP that makes it better for working with web things. Why does the language need to be designed to work with the web? That part of any language can be filled out with a framework quite easily, and arguably that means it's much…

> I don't think there's a good reason to design a language specifically for web projects. If that's how PHP works these days (I haven't used PHP in a decade or so), I'd suggest that might be a bad thing. It's very rigid, and if the language gets anything wrong that compromises the design of every project that uses it. Languages should provide simple primitives that frameworks and libraries build on. That has always b…

> That has always been the goal of PHP, to be a web framework in itself

This is untrue. PHP was a templating language and form-handler first and foremost[1]. It took a long time for it to move out of that (I'd argue up to 5.6) and become an actual programming language rather than a template language on steroids. Edit: we still have to move out of template mode in every file by adding a So, essentially, we now have web-frameworks built in a templating language. With, ironically, template languages written in that templating language. Nice, if you like recursion though.

[1] Early PHP was not intended to be a new programming language, and grew organically, with Lerdorf noting in retrospect: "I don't know how to stop it, there was never any intent to write a programming language - https://en.wikipedia.org/wiki/PHP#Early_history

Re: PHP – The Right Way

#108
post #89
post #74

Earlier quoted context omitted.

The fact that composer comes with an autoloader doesn't means that you have to autoload everything. You can manual include, define your own extra auto loader and use interfaces to quick swap for custom implementations. Like I said, +15 years. Composer is 9 years old. How do you think we handle this in our own Jurassic times?

You can manual include I don't think that will work with any code that came out in recent years. Because it all expects that its dependencies are automagically included via composer. In practice, every PHP based web application starts with Laravel or Symfony these days. So you are thrown into the composer workflow right away. And it would be a nightmare to fight it.

Nope. I don't use these frameworks. But thanks for trying to assume how php is on 2022 and how all php devs work.

Re: PHP – The Right Way

#109
post #34

I totally expected it to be a troll site. It's actually sensible advice. But, really, I suggest using other tools. We have nicer tools now.

> But, really, I suggest using other tools. We have nicer tools now. Debatable really. Within the web development space the options are rather limited in my opinion. Options: * Spring based apps - Downside JVM is a Resource hog * Python, Ruby, etc - The web frameworks are in my opinion not as full featured. Same with CMS systems. Also requires more resources. Also have limited OO features. * Go, Rust, etc - Really go…

No post body was provided.

Re: PHP – The Right Way

#110
post #94

Earlier quoted context omitted.

It had a role because PHP is the most used web technology in the world.

Not only that, I can almost guarantee that computers were involved in all of those failing projects as well, yet are not receiving any blame for it. Neither does the chairs. Damn chairs always avoiding blame.

Come on, CPUs aren't bedroom project hacked to write a bit of HTML. The depth of knowledge required to make one chip dwarfs all of PHP powered websites.
Post reply on HN