23 ms·
PHP – The Right Way
- jonwinstanley 5y agoPHP is actually a really decent option these days. And several libraries and frameworks built around it are flourishing.
- cies 5y ago> And several libraries and frameworks built around it are flourishing. Yes. > PHP is actually a really decent option these days. I beg to differ. What comparative options do you have experience with to base your claim on?
- Ronsenshi 5y agoI'm not the OP, but I have plenty of comparative experience working with Python and JS on the backend (node) and I find PHP to be a very decent option compared to those two. PHP has an amazing infrastructure of third-party libraries/packages around it, particularly if you're using PHP for web development. In comparison, Python simply does not have the same quality of framework for web like Symfony or Laravel. Django is good, but just that - good. And then there's the matter of speed with Python which is by all metrics slower than PHP. Then there's node. Node is significantly faster than PHP, but all that speed is wasted away because of all that nightmarish mess that is node_modules. Node infrastructure for backend web dev is nowhere near close to where PHP or even Python is.
- cies 5y agoSo compared to JS and $DYNAMICALLY_TYPED_LANG, PHP is "decent these days". These languages all suffer from very similar problems. Compare to C#/MVC.net, Kotlin/whatever, Go, Rust to get something noteworthy.
- thinkindie 5y agoAt least for Go and Rust, they have a much steeper learning curve. If you are a startup with limited funds you are not able to target engineers workings with those languages. If it's just a matter of speed, PHP already is good enough for the great majority of cases. The bottleneck is the data layer, usually. If your problem is being faster than the latest versions of PHP can achieve, you can certainly look for Go/Kotlin/Rust. But if you start your startup optimizing trying to shave off some milliseconds out of a response time you are setting yourself for failure. And in any case, languages like Go have their own part of quirkiness around the language or tooling (should we talk about how dependencies are managed in Go? that's ages behind npm/composer). Or shall we talk about the lack of exceptions, but then people regularly ask for them?
- norman784 5y ago> At least for Go and Rust, they have a much steeper learning curve. Agree about Rust, but I should differ from Go, as a disclaimer I never used Go, but read a lot of people switching from JS to Go and they have a very easy time doing so, maybe not everyone find it easy, and also it might to happen that the architecture you are used to work with in NodeJS is similar than the one that Go uses? > If you are a startup with limited funds you are not able to target engineers workings with those languages. I think Ruby/Rails will help you to build your project much quicker than Php/[Laravel | Symfony]. > If it's just a matter of speed, PHP already is good enough for the great majority of cases. Again also Ruby is pretty fast these days (if you want more speed you can use JRuby or TruffleRuby). > If your problem is being faster than the latest versions of PHP can achieve, you can certainly look for Go/Kotlin/Rust. Go: I should say yes, if PHP/Ruby isn't enough, this should your go to. Kotlin: I cannot speak about it, I'm not sure how popular is in this space. Rust: I love rust but I think this should be your last resort, if Go isn't enough anymore. But I can agree that work with Php is pretty easy (I worked with Php since 4.2 till 5.3, then tried it with some projects here and there with 7.x and 8.x) but I cannot stress how bad the tooling around php feels if you compare with others (ruby is bad too IMHO), JS with vscode, rust with rust-analyzer, etc. The only way I found a decent tool was with PhpStorm, but you need to pay for it (even the Laravel plugin needs a subscription), while the RubyMine is almost the same at least Rails works out of the box without an extra subscription for the plugins.
- jonwinstanley 5y agoThe main comparisons I have are building sites with Ruby/Rails and doing JS front ends attached to REST APIs. All three types of project have their own pros and cons.
- cies 5y agoThe fair comparison: PHP/Laravel to Ruby/Rails... How is PHP/Laravel better? I'm of the opinion it loses hard in every aspect.
- jacquesm 5y agoThere is one aspect where it wins hands down that trumps almost every other concern that you might have: availability of developers. This is a hard problem to solve.
- aeonflux 5y agoRaw number of developers doesn't matter at all. The ratio of offers to developers out there determines how easy the hiring actually is. I've tried to hire some quality PHP developers and it's as hard as Ruby/Python if not harder. First thing is, that you always get all the Wordpress people, who fixed one plugin and claim to have 10 years of PHP experience. Then you have to filter out all the 10 YoE who actually have 1 YoE done 10 times. For some reason all this is less of a problem in less popular stacks.
- jacquesm 5y agoIt does if the number is '0' vs 'some'. It usually depends on how and where you do your hiring. For those that only want to hire local developers it is very well possible that there are no local Rubyists, it is also possible that it is the other way around. Typically there are a lot more proficient PHP programmers than Ruby programmers around here, but if a company were open to remote workers the situation would right away change considerably. There is also the price factor to take into account. All in all, more often than not developer availability works itself into these choices.
- FinalBriefing 5y agoLaravel and its ecosystem is really great. I used to hate PHP, but now I find it quite enjoyable, at least in the realm of building websites. If you stick to modern versions and frameworks, it's a much different experience from PHP 8 years ago.
- marcusfrex 5y ago
- jcfariadias 5y agoYet this internet myth of "PHP no bueno" persists. Don't confuse the tool with the artisan. PHP is an incredible language that's getting more mature with each new release.
- awestroke 5y agoWhy do PHP developers insist on calling themselves artisans? Give me a call when PHP ditches backwards compatibility and cleans out all the shit from the standard library - 5845 global functions always available, most of which you are just supposed to know are shit... Just a nightmare.
- sdze 5y agoArtisans? First time I hear that. I certainly use PHP and never called myself an Artisan.
- BafS 5y agoIt comes from Laravel (https://laravel.com/); https://laravel.com/); "The PHP Framework for Web Artisans". The command line entry point is also called "./artisan".
- psychoslave 5y agoIsn’t "software craftsman" rather common? And artisan is just a synonym of craftsman. This is nothing specific to PHP. There people out there who take pride in delivering code that was created more as a piece of art.
- ahoka 5y ago(ˈɑːtɪˌzæn, ˌɑːtɪˈzæn) NOUN, denoting or relating to goods produced on a small scale using traditional methods Checks out!
- thriftwy 5y agoBut what's the point? The beauty of perl scripts, and later php templates, was in their BASIC-like simplicity. They were not secure or structured in any way, but very accessible. Once you add these frameworks, you realize you could have started with Python or Java in the first place and get more mature infrastructure and better language along the way.
- omgitsabird 5y ago> more mature infrastructure and better language What does this mean?
- thriftwy 5y agoPHP is a conceptually awful language. It is created by language amateurs and it shows in many early decisions such as the multiple thousands of built-in functions already mentioned. It had its benefits since those amateurs understood their use case and their users' capacity very well. But now all of that is gone and they are still stuck with a subpar language at the core.
- omgitsabird 5y ago> created by language amateurs > all of that is gone and they are still stuck with a subpar language The argument is that the language is "awful" and "subpar" because it has "early decisions" like "multiple thousands of built-in" global functions introduced by "language amateurs"? Sorry, but I remain unconvinced. I agree that there are real reasons that PHP fails as a language in particular use cases, but it seems rare that those reasons get articulated in these threads.
- thriftwy 5y agoIn the mid-00s the main selling point of PHP were shared hostings with mod_php which was a cheap way to host your own web site and database. Now with the cloud that advantage is utterly gone.
- 5y ago
- TekMol 5y agoMy problem with PHP is that it solves the issue of code reuse the wrong way round. In other languages, you can import code like this: import mail as mailer The external code ("mail") does not have to make assumptions how it will be called when it is used. In PHP, it is the other way round. Every piece of code needs to try avoiding namespace conflicts by prefixing the code with something like this: namespace Illuminate\Mail; Hoping the namespace (here "Illuminate") will not clash with other code.
- _def 5y agoYou can `use Illuminate\Mail as Mailer` if you want
- TekMol 5y agoThat is not what I mean. It would not prevent a clash with another "Illuminate" namespace. The problem is that the developer of "Illuminate\Mail" had to introduce the "Illuminate" namespace and hope nobody else uses it. Additionally it makes the code more complex. Every file needs to carry this "namespace ...." line now.
- ainiriand 5y agoYou can hope all you want but you won't be able to submit any duplicated namespace to Packagist.
- TekMol 5y agoThat is another consequence I don't like about the quirky namespace approach. It collects more and more problems like a ball of dust that gets bigger and bigger. The consequence you mention is that one depends more and more on tooling and services.
- CR007 5y agoDid you actually get these issues in a real use case? I've been developing PHP software for +15 years and I never had this namespace dilema.
- rbanffy 5y agoI 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.
- fraktl 5y ago
- bayesian_horse 5y agoI guess sometimes you are forced to use tools you'd rather not.
- unfocussed_mike 5y agoI don't know that many nicer tools than Laravel, to be fair. Especially Laravel + Lighthouse, which is an extraordinarily neat GraphQL layer considering the huge deployability you get with PHP. PHP is progressing towards a nicer language in a way that JavaScript, IMO, is not. And taking tens of millions of programmers with it.
- BafS 5y agoYou should also have a look to api-platform (https://api-platform.com/ https://api-platform.com/), it's based on Symfony and you can create Rest or GraphQL APIs with ease.
- unfocussed_mike 5y agoThat does look interesting. I'm currently using Nuxt/Vue (static) on the front end, with Apollo (this latter bit I will probably swap out). What is nice about Lighthouse is that it is schema-first. I am far less fond of the "auto schema" approach that e.g. WP-GraphQL uses. (Though WP-GraphQL is not bad; I'm also using that in a project).
- conradfr 5y agoOr don't, if you have a business data model that is more complex than a hello world.
- jbverschoor 5y agoWhy not install using asdf ?
- porker 5y agoWhen I looked ~ 2 months ago, PHP via asdf looked buggy and abandoned? I would _love_ to use asdf for everything, but outside a core set of languages/developers it doesn't seem to have the community around it.
- cortexio 5y ago
- psychoslave 5y agoActually, 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 most pointless project ever started, because the slogan for Subversion for a while was, CVS done right or something like that. And if you start with that kind of slogan, there’s nowhere you can go. It’s like — there is no way to do CVS right. So that’s the negative kind of credit. https://singjupost.com/linus-torvalds-on-git-at-google-tech-talk-conference-full-transcript/ https://singjupost.com/linus-torvalds-on-git-at-google-tech-...
- akie 5y ago
- berkes 5y agoWhy 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.
- rvnx 5y agoIt had a role because PHP is the most used web technology in the world.
- capableweb 5y agoNot 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.
- WalterGR 5y agoThat sure is a big a web page for having no table of contents! There’s a ToC on https://leanpub.com/phptherightway https://leanpub.com/phptherightway but I can’t link directly to it as the in-page link uses JS. (I’m on mobile though, so I can’t read the source. Maybe there’s an anchor someone else could link to.)
- jorams 5y agoI'm not sure what you're seeing, but for me the page starts with a massive ToC. On even smaller screens it turns into a button fixed at the bottom of the screen that opens a ToC in an overlay.
- WalterGR 5y agoHmm… Not sure what’s going on then.
- exikyut 5y agoTo answer the immediate question, I had a look and nooope, no <a name="">, not even <a> anywhere, that I could find. However I just (begrudgingly) realized this is somewhere text fragments can shine: https://leanpub.com/phptherightway#:~:text=Getting%20Started https://leanpub.com/phptherightway#:~:text=Getting%20Started To answer the bigger-picture question, the first thing I see (the above-the-fold part) upon loading the page (on both desktop and mobile) is a stylized ToC.
- benjamir 5y agoA language that changes the semantics of functions between minor versions has no "right way". "count()"less examples of crap. I have currently two weeks of code migration behind me because code running correctly on 7.0 fails on 7.3 -- while I see the reason for change was necessary I also see the hopelessness of rebuilding a flawed house with a fundament build on a pile of manure. And the good news given to me by a colleague is that they pulled the same stunt going from 7.3 to 7.4. It's like depending on stumbling alcoholics instead of language designers. Not much has changed since core devs tried to mitigate an overflow by testing for "$variable < MAXINT".
- cies 5y agoTotally agree. This is beyond taste or preference. Yes you can build a great app in PHP. But so you can in Kotlin or Ruby or ... Yes some have a career by starting with PHP. But that does not make it a good language for beginners. Same can be said (and to me is verrrry true) fro JavaScript. Language design matters. It shapes how you think about code. Talk to people who've learned AND USED many languages including some esoteric ones like Haskell, a LISP or OCaml. Then see what they have to say PHP and JS for beginners.
- berkes 5y agoFor me, a "beginner friendly language" has these properties: * A welcoming, helping and open community. * Built-in guidance or enforcement away from The Wrong Way and towards The Right Way. E.g. by making the former hard to do and the latter easy. * Ecosystem of high-quality, properly designed libraries and sample code. I see this in e.g. Rust. But e.g. JavaScript or PHP fail on all my three points. As does my main language, Ruby, sadly.
- magic123_ 5y agoWhile I agree on your three points, I don't think I would recommend Rust to a beginner developer.
- 5y ago
- nalekberov 5y agoThe 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.
- hotz 5y agoA poor developer can make any tool look bad.
- nalekberov 5y agosure, but why would you use poor tool in the first place?
- archerx 5y agoWhat is your experience to make such ignorant statements?
- nalekberov 5y agoI will just leave these here: https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/ https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/ https://software-gunslinger.tumblr.com/post/47131406821/php-is-meant-to-die https://software-gunslinger.tumblr.com/post/47131406821/php-...
- bowersbros 5y agoThat first article is a decade old.
- 5y ago
- trowawphphate1 5y ago
- TazeTSchnitzel 5y agoPHP is a language with various features that might make it attractive to certain people: • CGI-like execution model when used for the web, making resource leaks very difficult and encouraging scalable design • not only integers and floats, but also strings, lists and dictionaries as mutable value types (copy-on-write) — this is a big difference from JavaScript and Python • unusually for a dynamic “scripting” language: true classes and interfaces, and optional type declarations enforced by the runtime • a standard library that doesn't require import statements! • (a very new feature:) fibers, a way do asynchronous execution without every function in the callstack having to be aware of it • binary-safe strings without presumptions from the language about what encoding is in use • a very nice package manager • a highly optimised runtime But its history has made it a quite messy language which can be frustrating to learn, and which will always carry a higher mental burden than something like Python. It is a shame.
- babuskov 5y ago* duct-tape style of arrays that Just Work(tm) as arrays, hash maps, etc. without having to use any boilerplate code. It's the main reason why I still prefer PHP for quick&dirty scripting and data processing.
- Navarr 5y agoI love PHP "arrays" but there is one tiny gotcha that becomes more important as we do type-safety stuff more and more. `$a['1'] = 'string';` becomes `$a[1] = 'string';`. This appears to be the case for any fully-fledged decimal number where `(string)(int)$key === $key` So if you are expecting `array_keys` to return all strings, you might get surprised
- dotancohen 5y agoSome years ago I was appending underscores to key strings to avoid that. We're talking PHP 5 era. But even at that time stdClass was available. Today, I much prefer either using a stdClass object or actually making a real class when I reach for an associative array. They still have their use cases, though.
- deleted 5y ago[deleted]
- cletus 5y agoThe best features of PHP are: 1. Core API of stateless functions. Compare this to the bootstrapping requirements of, say, Java or Python; 2. CGI-like resource management in that you tear down everything after a request. Many people get upset at, say, the "global" keyword but "global" here just means "request-scoped". There are no STW GC pauses and it's difficult (but not impossible) to leak resources; 3. Executing code for a request is single-threaded. This is almost always what you want; and 4. PHP's copy-on-write arrays (that are really hash maps) that maintain insertion order are so incredibly useful and is almost always what you want. Crapping on PHP for things like function inconsistency (eg functions that use underscores vs those that don't, needle/haystack inconsistency) is a tired cliche and boring at this point. It really adds no value complaining about things that just don't matter and/or are historical. My biggest grievance is that Hack (FB's fork) is basically better in almost every way. The collection types (vec, keyset, dict) are better (eg less weird coercion defaults). The type system is leaps and bounds ahead of anything PHP has. Nullability as part of the type system is amazing. It's a shame Hack didn't become the dominant dialect. As for the book, I went through it and it's really solid. Good job to the authors and maintainers. It covers a lot of issues like register globals, sanitizing input, Unicode and so on. It also has links to more detailed information on any of these topics.
- Darmody 5y ago3. Executing code for a request is single-threaded. This is almost always what you want; And now with fibers you can launch "threads", which are not threads but work like them.
- xet7 5y agoI'm trying to learn https://haxe.org https://haxe.org , so that if some target language does not work, I could use some other target language. Currently I have hard time updating to newer version of Node.js, dependencies etc. I tried to code something with PHP 8.1 directly, but I presume any following update could change syntax etc.
- mapmap 5y agoIs there a page like this for c# dot net?
- faho 5y agoPHP is still full of awkward decisions. One that baffles me is that 8.0 changed it so all scripts default to a "C" (i.e. english, ascii-only) locale. [0] So this is now a scripting language that requires you to call `setlocale` for every script manually. Contrast python, which tries to fix the locale so it's at least UTF-8 aware. [1] [0]: From https://www.php.net/manual/en/migration80.incompatible.php https://www.php.net/manual/en/migration80.incompatible.php "The default locale on startup is now always "C". No locales are inherited from the environment by default. Previously, LC_ALL was set to "C", while LC_CTYPE was inherited from the environment. However, some functions did not respect the inherited locale without an explicit setlocale() call. An explicit setlocale() call is now always required if a locale component should be changed from the default. " [1]: https://www.python.org/dev/peps/pep-0538/ https://www.python.org/dev/peps/pep-0538/
- pas 5y agoIt seems awkward, but it's not. It picks picks a deterministic default instead of a "whatever you have in your OS environment". It practice all these env config initialization things are handled by the php.ini, and/or by a framework. (Plus using the mb_string ext is how any minimally sane string handling is done in PHP nowadays.) Yes, probably in ~10 years the PHP world too will move to a unicode by default setup :) But hey, progress!
- norman784 5y agoI want to like PHP, but it seems that there are so many better/modern alternatives out there, IMHO Go and Rust are the most notable new ones, Go is almost (if not yet) ahead of PHP in terms of community and resources (learning and packages), while Rust still needs a few years to establish (the async issue and few others) and the maturity of the ecosystem, there are no killer solution yet (maybe there will never be). I tried PHP last year (or should I say Laravel) and didn't found any good, the type system is bad for a project like Laravel, you have too many different files where you declare things and the type system doesn't now, so you end up without autocompletions (and warnings or errors from the php interpreter) you only catch those at runtime (I'm too used now to get the errors before run a project, or at least get a hind from the editor/IDE).
- pluc 5y agoYou didn't try PHP, you tried Laravel.
- tonyjstark 5y agoNot sure about your experience with Laravel, but I don’t see how the type system is bad for it. It works surprisingly well for me. With a bit of tooling I get even autocompletions for database fields when using Eloquent. PhpStorm with the (paid) Laravel plug-in are pretty awesome and give me more information during file-editing than for example Xcode. Laravel has also a pretty active and productive community and so many things just work out of the box, I’m not sure if Go or Rust has anything comparable. I have to mention: I didn’t touch Go for over a year now and never used Rust. I felt that Go is pretty easy to learn in its basics but quickly throwing things together for a prototype with DB access, I would go for PHP at any time.
- norman784 5y agoIt also could be that the learning curve is steep to get some things done and this was a side project that I wanted to get done. That could have contributed to my bad experience, also I'm not developing in php professionally anymore and sometimes when I want to get shit done, but this time it didn't worked for me. I would not go with nodejs/deno because it doesn't feel a resilient foundation, let's say you put your php server out there, it wouldn't crash easily or if it "crash" would not kill the entire server, so there are benefits with php in that regard, it feels more easy to fire and forget. Go should have my go to, but because never used didn't wanted to go that route, then Rust that is more painful than php in regard of the frameworks, there are not so mature ecosystem in the web category, but I can build a resilient system with rust, even I could write plain old sql that get's validated at compile time[1], that sounds amazing (well there are few drawbacks, but I like to be able to freely refactor the app in the future and the tooling tells me where I broke it, and with all other alternatives, except Go, there is no such library). So this is more personal preference and php didn't meet my expectations, that doesn't mean that php is bad, but for me and my use case is, we cannot blame to php yet, but I think the core developers must push even harder the type system, offer better 1st party tooling and more guaranties in regard of the integrity of your program, this is one take of rust that if it compiles it works so when you do code review you only need to review the logic :) [1] https://github.com/launchbadge/sqlx https://github.com/launchbadge/sqlx
- hooby 5y agoIt's a decent website - a useful collection of information and links to additional information, that can serve as a starting point to learn more. For those who use PHP, or for those who'd like to learn to use it, this might be useful resource. The same thing can't really be said of the comments in here though. I don't see how emotionally charged debates over what is the "best" or "worst" language, help anyone. It's almost as if some people can truly have their ego shattered, by someone on the internet liking another language than they do... Couldn't we just agree that there is no "best" language for every possible use case, and that everyone is allowed to like whatever language they want to like? It's not like the whole bickering is going to change anyone's opinion.
- pak9rabid 5y agoIn its early days (version 4 and below) PHP was a bit of a mess. However it got its act together with version 5, as it implemented an object model almost on par with Java's, which I thought kind of set the standard for how OOP should be done. It's just unfortunate that much of the mistakes with version 4 and below had to be kept in order to preserve backwards compatibility.
- lotyrin 5y agoMore than the design of the language itself, the culture suffered (and still suffers to a lesser degree) from the legacy of those bad designs, such that if you wanted to avoid a whole ton of awful codebases, poor practices and mediocre developers you could have easily done so by putting a language barrier between you and them and "graduating" to some other language. Many teams and codebases these days have moved onwards and upwards toward a world where sensible design exists.
- dec0dedab0de 5y agoYou're right, but you're missing the emotional damage many hackers of a certain age feel when they remember troubleshooting PHP problems, or constantly having to look things up, before they left for whatever their language of choice is now. People complaining about PHP are mostly just venting frustrations from 15 years ago.
- throwtcp5327 5y agoJust wanna dump a bunch of similar PHP sites you might find useful: (The only proper) PDO tutorial: https://phpdelusions.net/pdo/ https://phpdelusions.net/pdo/ Organize a php project according to industry best practice: https://github.com/thephpleague/skeleton https://github.com/thephpleague/skeleton PHP Best Practices - A short, practical guide for common and confusing PHP tasks: https://phpbestpractices.org/ https://phpbestpractices.org/ Modern PHP Cheat Sheet - A to-the-point summary of all awesome PHP features: https://front-line-php.com/cheat-sheet https://front-line-php.com/cheat-sheet Laravel, PHP, JavaScript: https://freek.dev/ https://freek.dev/ PHP security: https://paragonie.com/blog https://paragonie.com/blog
- haolez 5y agoSlightly of topic, but is Hack a thing outside of Facebook? I'm a little thrown off by the confusing standard library of PHP, but I don't know if using Hack instead would solve more problems than it creates.
- irq-1 5y ago> Right now PHP does not support Unicode at a low level. There are ways to ensure that UTF-8 strings are processed OK, but it’s not easy, and it requires digging in to almost all levels of the web app, from HTML to SQL to PHP. We’ll aim for a brief, practical summary. https://phptherightway.com/#php_and_utf8 https://phptherightway.com/#php_and_utf8 This is a web language? PHP still has these kind of issues because of its culture: Get it done now and ignore any future costs.
- ofrzeta 5y agoUpdated in January but not really up to date. It doesn't mention union types, the nullsafe operator, matching expressions and a lot of other features you can find here: https://stitcher.io/blog/new-in-php-8 https://stitcher.io/blog/new-in-php-8 Maybe not everything is "the right way" but at least the nullsafe operator is, I think.