Live data from Hacker News

An Internet of PHP

timotijhof.net

251–260 of 333 posts

Re: An Internet of PHP

#251

Ironically enough, if people actually tried PHP, many would be amazed, especially at the quality frameworks. Productivity is very high in something like Laravel, and compared to JavaScript frameworks PHP frameworks are much more feature complete and well though out. I'm a big fan of trying out different stacks, and I think a lot of people would love Laravel if they tried it. Give it a shot using PHPStorm and Laravel…

As a PHP developer of 10+ years, large frameworks like Laravel and Symfony still bewilder me. I really have no idea why 99% of people would ever want to use them. They add a layer of complexity over the top of PHP such that instead of learning how to write PHP, you need to learn how to write the framework. Let's take an example right from Laravel's homepage: Authenticating users is as simple as adding an authenticati…

The reason why many use frameworks like Laravel, Symfony, RoR or Django is often because they have non trivial needs. If I need to do something very simple like a small blog I might just throw something together on my own.

I personally have a large prject with a ton of code that was written in the last 16 years from when I was very inexperienced to now. After a while you realize that patterns are important, and you start building more and more features to make development and maintenance simpler and faster.

Here is a list of things I created over some years for that project: - Authentication system that supported different types of login. - Pretty routes. - Simple dependency injection container. - Emailing. - A templating system. - A scheduling system. - A worker pool. - Reusable forms. - Simple DB migrations in code. - Caching system. - A file storage system. - Data seeding. - Testing. - Websockets. - Asset bundling and versioning. - Localization. - Payment integrations. - +++

Sure, I could do it the JS way and find different packages instead of doing it myself, but I don't want to rely on a bunch of projects as that quickly can become maintenance hell.

After a while you realize that you're basically reinventing the wheel. Is Laravel and Somfony complex? Yes. Does it sometimes seem like magic? Yes. Is it hard to use, modify or figure out how it works? No.

You might not know why 99 % would want to use them, but I'd agrue that most probably should when the project achives some complexity. That way you can reap the benefits of the work and experience of thousands of contributors behind these projects.

I am one of those "I want to know what happens in the background" people too, and it's not that hard to figure out how Laravel works if you want to know. But most developers are not interested in how the framework they are using really works. The questions you have about what the auth middleware is, how it works, and what the Illuminate namespace is for(Laravel) is easy to figure out by checking the docs.

Laravel is definetly an opinionated framework, but personally I think most of the options are good ones.

Re: An Internet of PHP

#252
post #49

I feel like a lot of this is mostly a commentary on WordPress.

Which it should be, since WordPress is such a huge part of the PHP ecosystem. Laravel is a distant second. To talk about PHP without mentioning WordPress, whether in a good light or not, would be like discussing Ruby without mentioning Rails.

No doubt but it calls into question some of the reasoning in the article about PHP itself being so great. Like, people write a lot of VBA because of Office but I would not conclude that that’s because VBA is such an excellent environment to work in and more because Office is a great product and VBA is how you interact with it.

Re: An Internet of PHP

#253
post #71

I like PHP, one issue which I face with PHP though is, that it is difficult to create a self-contained docker image. With node.js or java spring boot i can build an application with an http endpoint and create a single docker image with all included easily. With php I need 2 distinct containers, e.g., nginx, php-fpm and the code mounted on a volume to the the containers. So it seems to be more difficult for setup and…

PHP has had a built-in web server since version 5. People use Apache or nginx because they want to, but because they need to.

the embedded server is great for dev, but useless for production. for example any url that contains a dot "." is considered to be a static file. so for example this path does not do what it's spposed to do /login.php?token=fghjjbjkkooll.rfcgg

Re: An Internet of PHP

#254

Ironically enough, if people actually tried PHP, many would be amazed, especially at the quality frameworks. Productivity is very high in something like Laravel, and compared to JavaScript frameworks PHP frameworks are much more feature complete and well though out. I'm a big fan of trying out different stacks, and I think a lot of people would love Laravel if they tried it. Give it a shot using PHPStorm and Laravel…

Out of curiosity, in your projects where you use PHP with frameworks such as Laravel, do you do server-side rendering, or SPA applications? I prefer the former but I wonder what's the trend now for the people into Symphony, Laravel, etc.

I have mostly used SSR, but in the last years I'm sometimes using Inertia with React/Vue/Svelte and SSR too. Not sure if there are any clear trends. Personally I prefer plain old blade templates, and I only use FE frameworks if I think it makes sense.

I don't know how the experience is with Livewire, but I've heard a lot of people like that too.

The common options with Laravel is plain blade templates[1], Intertia(React/Vue/Svelte, SSR optional)[2] or Livewire[3].

[1] https://laravel.com/docs/10.x/blade

[2] https://inertiajs.com/

[3] https://livewire.laravel.com/

Re: An Internet of PHP

#255

I like PHP, because it has a familiar C-like syntax and great tooling, like composer, and frameworks, like Symfony. The language has warts, but it's improving. I think its strength is its architecture, namely shared-nothing state and concurrency at the web-request level. [1] [1] https://slack.engineering/taking-php-seriously/

HHVM is evidence of the weakness of PHP and is a bandaid hack, but the article spins this as justification for PHP. What would you do if HHVM didn't even exist? Admittedly PHP has had recent performance gains, but by no means would it ever be a first choice in any backend service architecture.

> What would you do if HHVM didn't even exist?

If you're referring to the Slack article, it is a bit out of date.

PHP has since added stronger typing and better performance. I don't think using HHVM is very popular.

Re: An Internet of PHP

#256
post #66

Earlier quoted context omitted.

> The ability to interleave code and HTML was also tacky and never taken seriously but I think touted highly by some as a killer feature. And yet people seem to keep inventing variations of this as "templating" languages.

That presumably take care of the escaping rules and grammar of the output language, unlike the giant string concatenator that is PHP.

Yeah, a big problem with the traditional PHP-in-HTML approach to generating web sites is that it's one of the areas where PHP hasn't dramatically improved since the early days. Later templating engines learned from the problems people encountered with PHP and were built to be aware of the output format, and PHP never did that. A lot of work was put into writing templating engines in PHP that in retrospect really should have instead been a language mode for PHP itself.

We would have seen dramatically fewer bugs and injection attacks over the years if PHP had made "> a perfectly safe and normal thing to write back in 2005.

Re: An Internet of PHP

#258
post #257
post #247

Earlier quoted context omitted.

Because now the behavior of comparison depends on whether the string looks like a number.

Arguably 48 == "48" should be true. If this doesn't work for you, stick to ===.

Thank you, I'll stick to languages where you can't just compare numbers and strings without an explicit conversion.

Also, should 48 == "48.0" be true? How about "048", "48.", "0x30", " 48 ", "48foo", "3*16", "XLVIII", "forty-eight"?

Re: An Internet of PHP

#259
post #99

Earlier quoted context omitted.

And they are humble. They know their state, the flaws in their language and the long problematic history they have. They cherish their languages but are not fanatics.

PHP has its fair share of snobbery as well. Non-framework devs look down on Symfony, who in turn look down on Laravel devs, and everybody looks down on WordPress devs.

> and everybody looks down on WordPress devs.

Maybe because they have been actively sabotaging progress and dissing those pushing for progress? gophp5 in 2008 pushed everyone but Wordpress off PHP4 and some Wordpress core committers as recently as 2017 have called gophp5 an "abysmal failure" despite it was anything but.

Re: An Internet of PHP

#260
post #120

Earlier quoted context omitted.

Modern PHP may as well be a new language. But then node came along. It's almost like PHP users couldn't stand a clean ecosystem.

Clean???¿?????? Dude, Node is as broken as PHP. And it starts from having no standard library leading to hell like leftpad and general software supply chain holes that PHP never had in the same quantity. It isn't clean. Node was just shinier and had more applications to leveraging it for a shiny frontend.

I think that’s what he’s saying: That they jumped from php to another hot mess. At least that’s how I read it.
Post reply on HN