Live data from Hacker News

Modern PHP Cheat Sheet

front-line-php.com

101–110 of 127 posts

Re: Modern PHP Cheat Sheet

#101

Earlier quoted context omitted.

> From what I have seen, older people in our trade seem to recommend against PHP due to it having a terrible relationship with consistency, functionality, performance, As an older person in the trade, I don't agree with the other older persons. Only consistency is a problem with PHP code, and that is largely NOT caused by PHP. Inconsistency is the product of developers coding without any real thought about how to abs…

I am honestly and truly trying my absolute best, but no matter how hard I try, I again and again completely fail to sufficiently and comprehensively put into meaningful words how the inconsistency of the PHP language doesn’t play a role AT ALL when building actual web applications for actual users. It just. Doesn’t. Matter. Choose Symfony or Laravel, and you are in for a wonderful development experience, from setup t…

I agree with you, and it's super hard to explain. But if you have the right type of project requirements, Laravel is unbelievably great to work with. I love other languages more than PHP, but for a real world, client facing project that I want to be mostly hands off, Laravel would get my vote 9/10 times.

Re: Modern PHP Cheat Sheet

#102
Super cool:

> Union Types - Combine several types into one union, which means that whatever input must match one of the given types: `function find(int|string $id)`

TypeScript and PHP have the distinct honor of being a popular language with ad-hoc union types (not the concrete subclass/enums that other languages seem to think are sufficient).

Re: Modern PHP Cheat Sheet

#103
post #32

Earlier quoted context omitted.

It's so nice to see a comment giving PHP the praise it deserves. Honestly, PHP is a good, if not great, language to use for building solid web apps fast. People seem to love to hate it because it's the "cool" thing to do. Yet PHP developers continue to ship things faster, while JS devs are probably still fiddling with their Node environment setup...

Not only shipping things faster but testing faster, scaffolding faster, debugging faster ... the tooling for PHP is much more mature than it was 6-years ago and there are so many GOOD packages out there that haven't been forked and copied 20x over. Really happy to be working with it again, even if on the side for now.

Anecdotal - my experience is the opposite. I have two large PHP side projects currently (vanilla and Drupal) and I find working with PHP and Composer to be a much slower experience overall than my day job developing with TypeScript/Node and JavaScript/React.

Re: Modern PHP Cheat Sheet

#104
post #60

A Reddit post from a few years ago explains pretty well why PHP has such a terrible reputation: https://www.reddit.com/r/webdev/comments/5tqoqa/web_devs_wha... PHP should have chosen to undergo a rebranding a few years ago, if you ask me. The stigma it has to deal with is probably unsurmountable and will be forever. If you think PHP, you think WordPress and Joomla, and that means "hacks and vulnerabilities"... It's a…

How do you find those kickass ones on Fiverr among a sea of bad ones?

the good ones are not on fiverr ;)

Re: Modern PHP Cheat Sheet

#105

I'm using Laravel/PHP for a new project and it's been a joy . A true joy. After spending the last 6+ years writing backend services in Node, PHP feels like a breath of fresh air. No restarting the server, no compiling errors from babel/typescript wackiness, no blocking threads, server-side templates out-of-the-box, and so much more. PHP has come a really long way, I really hope to see it's resurgence some day after e…

same here. Been using Laravel has my framework of choice of my freelance work and I'm able to accomplish things fast. I just love to use it everyday!

Re: Modern PHP Cheat Sheet

#106
post #92

Earlier quoted context omitted.

Do you know why that is? php > echo md5('240610708'); 0e462097431906509019562988736854 php > echo md5('QNKCDZO'); 0e830400451993494058024219903391

Here is the explanation: https://www.php.net/manual/en/function.md5.php#123392

[deleted]

Re: Modern PHP Cheat Sheet

#107

Earlier quoted context omitted.

Do you know why that is? php > echo md5('240610708'); 0e462097431906509019562988736854 php > echo md5('QNKCDZO'); 0e830400451993494058024219903391

Would this be avoided by using a string comparison function? https://www.php.net/manual/en/function.strcmp.php

Yes.

  php > echo strcmp(md5('240610708'), md5('QNKCDZO'));
  -4

Re: Modern PHP Cheat Sheet

#108

Earlier quoted context omitted.

Not only shipping things faster but testing faster, scaffolding faster, debugging faster ... the tooling for PHP is much more mature than it was 6-years ago and there are so many GOOD packages out there that haven't been forked and copied 20x over. Really happy to be working with it again, even if on the side for now.

Anecdotal - my experience is the opposite. I have two large PHP side projects currently (vanilla and Drupal) and I find working with PHP and Composer to be a much slower experience overall than my day job developing with TypeScript/Node and JavaScript/React.

I would guess that a lot of the slowness is not from PHP itself, but the way your specific projects are using it. With the vanilla PHP project, the slow down may be caused by poor design decisions from other developers.

With Drupal, the code quality of the core is generally okay, however the added inertia may come from a "square peg, round hole" situation, where the CMS is being used for an obscure purpose for which it wasn't really designed. This is quite common in the wild, probably due to the low barrier to entry and the fact that people will use what they are comfortable with to solve every problem under the sun (not dissimilar to the prevalence of Excel throughout the world of finance for a variety of completely inappropriate use cases).

Re: Modern PHP Cheat Sheet

#109
PHP's main problem is its very shallow learning curve.

The 5840 built-in functions provide easy ways to get many useful things done with minimal dabbling.

In other words, one can be a "scripter" instead of a "programmer", and for many projects that's 100% OK.

Other languages automatically filter out "scripters" from their field by demanding a certain level of mental abstraction to produce anything moderately useful.

While there is absolutely no difference between a good programmer using PHP, or a good programmer using any other language/environment, but there is a big difference between the median levels and below.

This in turn lowers the reputation of the field, and it becomes uncool to put PHP on one's resume, therefore the more capable programmers propagate out to other languages, which further lowers the median, etc.

This happened with Perl, too...

Re: Modern PHP Cheat Sheet

#110
post #91

My absolute favorite thing about PHP is the arrays and the ease of working with them. Whenever I find myself working in another language dealing with loads of data I'm immediately thinking of how easy it would be to accomplish it in PHP. And I've been loving all the new additions to PHP over the last few years as well. Version 5 was rather limited but since 7 it has grown into an actual programming language for which…

Is it really useful to have ordered map as the "only" collection type? I guess it might be Stockholm syndrome - but I'm quite comfortable with a "list/array" type (numeric keys, ordered) and a "map/hash_map" type (objects as keys). Especially give that with phps "power" you can: $array = array( 1 => "a", "1" => "b", 1.5 => "c", true => "d", ); var_dump($array); Ouputs: array(1) { [1]=> string(1) "d" } https://www.php…

[deleted]
Post reply on HN