Hacker News new | ask | show | jobs
by tonysickpony 2706 days ago
I really enjoy articles like this. In fact if anyone know some high quality resources of modern PHP, please give me some pointers. I am somewhat proficient in programming, and a recent project requires me to work in PHP. I know people in the industry likes to make fun of php's design flaws and quirks, but a few weeks in, I feel it is alright. The community around it are making solid improvements. The only frustrator is that once too often when I search something the top results are all W3C school tutorials from 2004.
6 comments

I work a lot with Laravel, it is a hell of a framework, documentation is amazing, it's clean, very well done, super extensible, there are a lot of extensions (just have a look at the Spatie library) and allows me to build up a website/webapp backend with a good API, basic authentication and other basic features in minutes.

Also, and this is a really strong point, can manage assets super easily, React and Vue stacks are supported out of the box with laravel-mix.

And if you need something lighter (for building just an API for instance) Lumen is the light version of it.

I have a lot of experience with PHP and Python frameworks, Laravel comes as absolute top for me.

https://laravel.com/

https://spatie.be/open-source

https://lumen.laravel.com/

As someone who recently took on the Laravel learning curve, be aware that Laravel moves atypically fast. That is, something in say version X.Y might be different in X.Y+1 or Y+2. That ends up manifesting itself as a lot of noise when you're asking The Google for help.

It can be frustrating. When you're on a deadline it can be unnerving and then some.

Ha ha. Joke's on me. I just inherited at 3.x site. Getting it upgraded to 5.5 looks like it will be a half-total rewrite.
If you can get it to 4.2, you may find this helpful: https://laravelshift.com/
That's true for additional features, but rarely does documented behavior change in a point release. That usually only happens when there is a security bug.
That’s not true. It happens quite often. Variables, classnames, php targets are changed on a whim.
More than twice The Google found me solutions that were out of date by Y+1 or Y+2.

I finally got into the habit of making sure what I found was current. But that doesn't prevent so much noise in the Laraval + The Google signal.

Yes. That's probably the main reason why I keep developing in php. The fact that Laravel and Lumen are so well thought out.
Thanks man. I have heard a lot of good words of laravel. Will definitely have some experiment with it.
Gold standard is https://phptherightway.com/

Also the symfony documentation and particularly the source code is an excellent example of modern high quality PHP.

Thanks, man. That are some good reads.
Also see the pragmatic counterpoint: http://www.phpthewrongway.com

They make for a good read together.

Most complainers haven't looked at PHP the last 20 years or so. A lot has happened since v4 but it's fun to make fun of people I guess.
Why take it personally? We complain about the language and to some extent the original creators of the language -- not its users. Complaining (at its best) makes things happen.

I worked with PHP in '98 (ported a perl thing into this cool new web language) and then much later in 2014-2017. I found much to complain on the second time :) PHP7 is a good update, nevertheless.

Has PHP removed features?

A language is just as much about what features it excludes as to what it includes.

Yep. In addition to the removal of register_globals sometime back, several deprecated extensions (like mysql_* and ereg_*) and magic quotes have also been removed.

Some other deprecations: http://php.net/manual/en/migration70.incompatible.php

Honest question: after all this PHP evolution is it any better than Java, today?

My impression was that PHP post-PHP 4 was basically cloning Java. On top of that, unlike Java, PHP started from the bad base provided by old PHP versions.

If your project is already in PHP or you are super proficient with PHP, ok, but otherwise I would just start directly with Java.

The PHP world clearly had some Java envy rolling into the 4 to 5 era. The problem with that was less that PHP was trailing Java (although that was true in some real respects) and more that people seemed to be assuming the problem with PHP was that it wasn't using enough high ceremony and design patterns that existed to solve problems for static/manifestly typed languages (and PHP, like other dynamic/scripty languages, had different solution idioms for). Writing Java in PHP really was/is suboptimal.

The popularity of Ruby/Rails and to some extent Python and node did a lot to shine a light on the productivity possibilities of embracing the dynamic/scripty side -- at its furthest edge, you can see this in how Java has changed and brought in some of the strengths from the dynamic/scripty world. But also I think it started a good part of the PHP world down the road of thinking about what the actual problems with working in PHP were and working on those.

I'm not going to enumerate PHP's strengths because I'm (a) weary of doing so and (b) have decided for the moment it's possible there's more value in keeping the various possible competitive advantages quiet. But suffice it to say that PHP has always had strengths (along with its real weaknesses) that a lot of the dev world seems astonishingly blind to, so it's a misunderstanding to think of past versions as nothing worth building on. Filing off some of the warts, adding helpful and convenient features, and bringing performance back towards first in class rather than buying into enterprise cargo culting has really given it a boost and even made it more fun.

It's definitely not the right tool for every problem/project, there are still things missing from the language that I sometimes wish I had when using it, but it's great for a certain class of web applications.

"Why isn't Java used for modern web application development?" https://softwareengineering.stackexchange.com/questions/1020...
That's ridiculous. Startups tech is more about fashion than anything. Half decent developers using modern Java tools can deliver things maybe 5% slower than any developer using a dynamic language and you get way better speed and stability using Java/the JVM.
> The only frustrator is that once too often when I search something the top results are all W3C school tutorials from 2004.

There is no such thing as "W3C School".

There is the W3C, which is a standards body that publishes various web technology specifications such as HTML, CSS, and DOM specifications.

Then there is W3 Schools, who are entirely unrelated to the W3C. They publish low quality tutorials and sell worthless certificates. They chose a name which confuses people into thinking that they are somehow "official"; this couldn't be further from the truth.

Check out the Symfony docs and https://symfonycasts.com/.
Mostly look at Symfony, the framework or the individual components. It's a bit too "enterprise Java" sometimes but otherwise it's very solid (and a very well run project).

Laravel seems more popular in the US but it stills uses many Symfony components.

Although Laravel promotes ways of coding that keeps the code readable and more fun that the traditional Symfony/Java way (Like really long class namespaces and names that have redundant strings in them etc).

Laravel uses Symfony components but the APIs are a lot more fluent and more natural to use.