51 ms·
PHP 8.2
- Dachande663 4y agoNot as big a leap compared to 8.1 since Nikita left full-time development, but still a good trend. Lots of good changes to types (removing dynamic properties by default, redacted properties, readonly classes, more complex types etc). https://stitcher.io/blog/new-in-php-82 https://stitcher.io/blog/new-in-php-82
- mhitza 4y agoThe SensitiveParameter attribute is a really nice addition that isn't highlighted on the release page.
- trog 4y agoThis is the post I came looking for! Disappointed but not surprised I had to wade through all the usual comments about "fractal of bad design" and "actually, PHP is great" to find someone actually talking about the new features.
- vegancap 4y agoI haven't used PHP in almost a decade, but I've been super impressed with what I've seen in the most recent few versions. Looks really cool, it's gotten me tempted to dust it off again at some point
- XzAeRosho 4y agoI've been working professionally with PHP for the last decade or so, and the last few years have been so good. The changes are very welcomed, and the performance improvements are amazing in general. The codebases that you can create nowadays are light years away from what you would see 10 years ago. And the frameworks have improved alongside too.
- pluc 4y agoSame. The vibe difference between a modern php app and an old php app is so tangible, it makes you constantly appreciate it.
- pwython 4y agoIt has been a decade for me too, if not more. What's your favorite framework/tools/tips? I'd love to get back into it.
- conradfr 4y agoPick one framework between Symfony and Laravel and follow the docs. Maybe read https://stitcher.io https://stitcher.io posts about the new features since 8.0 to have a grasp of the language changes.
- martin_a 4y agoWhat would you recommend? Looking for a more robust and streamlined solution to build small(er) pages...
- esskay 4y agoNot OP but I'd personally recommend Laravel over Symfony if you're just getting back into it. Fundimentally they are very similar, but Laravel's less of a learning curve and these days has a significantly larger community. There's resources like laracasts which take you through from the basics to highly complex concepts without it feeling like you're being lectured. One benefit of Laravel is that under the hood it shares a lot of Symfonys core components so should you decide to switch at some point it's not too much of a learning curve.
- martin_a 4y agoThanks, I guess I'll look into Laravel then.
- 4y ago
- Thaxll 4y agoThe fact that the language is weirdly executed server side is a non starter imo. PHP is still the only language doing that no? Edit: I'm talking about the php code being compiled / run by an external process which makes the whole thing staless. It was a "working" design when people were dropping .php files in ftp folder on some hosting provider.
- zmxz 4y agoWhat does "weirdly executed" mean? I can't even guess so would you be so kind to clarify?
- paulryanrogers 4y agoWhat is weird? That it's stateless, and therefore often deployed with a module or FPM?
- ape4 4y agoYou can run it standalone. On the command line: "php myscript.php"
- zmxz 4y agoYou're not making any sense with this sentence or explanation, why even comment if you're unaware of the execution model? What "external" process are you talking about?
- Thaxll 4y agoWhy do you need mod_php, php-fpm, zend etc ... to create a PHP "server"? This model is imo outdated, why can't we create a PHP server that just runs without the need of something external.
- zmxz 4y agomod_php: to embed PHP binary into Apache process. It's related to Apache, not PHP. PHP-FPM is the server you're talking about. It's a supervisor process that forks into N child processes, each handling incoming request. Supervisor deals with child exits and respawns, keeping the whole thing alive and robust. This model is what PM2 does for node.js to keep it alive when it crashes. There's also PHP command line interface that lets you run a server by starting a PHP script, in which you get to access OS's event loop and various other lower level interfaces. You don't seem to be knowledgeable about the topic and you're assuming something entirely wrong. Why didn't you google before this discussion? One can start a synchronous, process-based server or event-loop async one. What exactly is outdated here and how does ANY other language do it differently?
- dncornholio 4y agoDo yourself an extra favour and start with Symfony or Laravel. These frameworks are a joy to work with.
- sam_goody 4y agoWe picked Laravel ~15 years ago, and regret it. For getting up and running, it saves time. For large projects, it adds leaky abstractions, overhead for each request, a need to upgrade another layer - with poor upgrade compatibility (in our anecdotal case), and very little gain. And it has it's own learning curve, which with modern PHP may be redundant. Symfony looks better in that it is more of a library and less of a framework, though of course that has its own tradeoffs. IMO, the weakest part of PHP is the db functions (both PDO and mysqli/postgres)
- Aachen 4y agoDeprecated variables in strings? Or just when using the curly braces syntax for some reason? Unlike with every other entry there's no link but this sounds like the biggest change since PHP 4. Anyone know where to find more info?
- TimWolla 4y agoOnly this specific curly braces syntax, which is less powerful than the still-supported '{$foo}' variant: https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation https://wiki.php.net/rfc/deprecate_dollar_brace_string_inter...
- Aachen 4y agoAh, okay that's a much smaller change then. Thanks for the info and link! Kinda odd that Bash has had this syntax since forever, Perl as well, JavaScript went out of its way to add it as well, and now php is like: let's remove this syntax specifically but allow typo variants of it! Oh well. Not like I was using it, that is, I use the bare "$foo" syntax and try not to make string interpolation too complicated with inline expressions or some such. Just, I could have seen the logic behind switching to the more universally supported syntax and deprecating something else rather than doing their one-off thing.
- colonwqbang 4y agoIn bash/shell the expression $a is "just" a shorthand for ${a}, which is the more general syntax. Shell does not really make a distinction between string interpolation and ... well, everything else. It's a bit like how we don't always have to write out the curly braces of an if statement in C. I'll also point out that in shell assignment looks like a="foo" not $a="foo" The dollar sign of shell feels to me more like an operator you use when you want to access the value of a variable. Not a part of the name of the variable as in PHP.
- jorams 4y agoPHP string interpolation has 3 possible syntaxes: $var, {$var} and ${var}. The last one is now deprecated. I've never seen it used in the wild, and it has some odd limitations. It's discussed in the RFC[1]. [1]: https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation https://wiki.php.net/rfc/deprecate_dollar_brace_string_inter...
- tored 4y agoThere is an error in the examples on this release page about traits with constants, it says that return self::CONSTANT; // Fatal error however that is actually allowed, what is an fatal error is return Foo::CONSTANT; // Fatal error compare https://3v4l.org/dIeOk#v8.2rc7 https://3v4l.org/dIeOk#v8.2rc7 https://3v4l.org/11of1#v8.2rc7 https://3v4l.org/11of1#v8.2rc7 Prohibit direct access through a trait name https://wiki.php.net/rfc/constants_in_traits https://wiki.php.net/rfc/constants_in_traits
- nixcraft 4y agoPHP 8.2.0 changelog - https://www.php.net/ChangeLog-8.php#8.2.0 https://www.php.net/ChangeLog-8.php#8.2.0 PHP supported versions - https://www.php.net/supported-versions.php https://www.php.net/supported-versions.php
- user3939382 4y agoThe worst part about PHP is constantly hearing from its detractors, who are often people who haven’t used the language in many years. Haystack needle order, $, fractal of bad design, it just gets old. The language isn’t perfect but I love working with it, these 8.1 and 8.2 improvements have really made it sweet. My biggest gripe at the moment is the (very old) behavior of e.g. preg_match() and sort(). You’ve got a small handful of these common functions that operate on their input by reference/in place which is gross. A new version of these would be welcome.
- cies 4y ago> I love working with it Great! Keep using it! Ignore us. We (detractors) also had to use it and have since learned (hopefully several) other languages that (not looking at you JS) we like much better... :)
- zmxz 4y agoWhat was the motive behind this post? What do you hope to gain? If it's recognition for learning <insert-language>, how do I provide it to you?
- sdiacom 4y agoSomething that is extremely common in the PHP community, and pretty much absent in any other programming community, is this knee-jerk aversion to the idea of learning another language, and this sort of derision to those who do. Have you consider that people who learn other programming languages are not doing so in order to claim that they're better than PHP programmers, but for their own intrinsic reasons? It's such a weird, fragile ego situation. Does everyone else have to pretend that PHP is the only language that exists in order to placate your sense of inferiority?
- zmxz 4y agoLet's recap: post about PHP, ex-PHP user posts completely false info. Your reaction: "why do PHP devs get upset when ex-PHP users write false things about the language? Also, none of you know any other languages". Thanks for the ad-hominem, that concludes this discussion. Also, plenty of people who use PHP know so many other languages. You don't appear to be a professional in this industry, especially not with this kind of discourse. Take care.
- trey-jones 4y agoMany are praising the recent releases of PHP for their quality and performance improvements, and I wouldn't dare argue against that. However, the current release schedule of PHP makes things a little bit difficult for sysadmins. We're now using php-fpm docker containers so that we can (sort-of almost) keep up with PHP updates without doing OS upgrades every single year. A LTS version would be welcome!
- Y-bar 4y agoPHP 8.2 will get official security updates until December 8, 2025, how much longer do you need?
- jjice 4y agoIt's not the same, but MySQL offers like 8 years https://endoflife.software/applications/databases/mysql https://endoflife.software/applications/databases/mysql. Obviously very different software with different goals and monetization models (none vs some). Not apples to apples but figured it was a good example of what someone might have in mind.
- Y-bar 4y agoPHP 7, released December 2015, 7 years ago, still gets bug and security patches. Seems similar to me.
- trey-jones 4y agoIt doesn't though (granted, support for PHP 7.4 only ended 10 days ago, so you can be forgiven for not knowing): https://www.php.net/supported-versions.php https://www.php.net/supported-versions.php But PHP 7.4 is not compatible in many ways with PHP 7.3, so lumping them together is not OK. As you can see, PHP 8.0 which was only released two years ago, is no longer receiving active support. Definitely, database LTS is not comparable to programming languages. However such rapid releases of breaking versions is a relatively new phenomenon (thanks NodeJS), and I get the feeling that you've never actually supported a software project for 5+ years.
- tiffanyh 4y agoWhat’s a feature that PHP is missing, that if it had it - would garner it more respect? Note: I think PHP is way under appreciated.
- dncornholio 4y agoHaving an event loop that can freeze your whole application, is my guess.
- rob74 4y agoHmmm, how do I say this without being downvoted... it's not as much a feature that is missing, it's unfortunately the whole origin of PHP as a language that wasn't really carefully designed, but just kinda grew organically (famously Rasmus Lerdorf didn't intend it to be a general purpose programming language at all, but "just" a templating language). Despite the efforts since PHP 7 (also partly already PHP 5) to make it more "professional", it won't be possible to completely shake off this legacy. Don't get me wrong, I like PHP as a no-nonsense language in which you can get web dev tasks done quickly and effectively, and I would pick PHP over Node any time, but the inherited warts are undeniable and at least some of them are here to stay.
- Ciantic 4y agoAs someone who has written in past a lot of PHP and Python, I find it interesting that PHP devs can do a lot of breaking changes, and don't get a huge amount of flak for it. Python 2 -> 3 change really was painful for Python community, but PHP does these almost fundamental breaking changes so often, that maybe people just get used to it? I haven't really followed Python past version 2, but I think they are less likely to ever do such amount of breaking changes. There must be a lot of unmaintained PHP codebases that will break if PHP is updated by hosting provider etc. Someone must be pulling a lot of hairs because of this. Edit: Those dogpiling there, I rest my case with josefresco's comment: https://news.ycombinator.com/item?id=33907628 https://news.ycombinator.com/item?id=33907628 It's painful. Dropping dynamic properties? That will be a lot of fun. WordPress is probably biggest segment for PHP usage.
- TazeTSchnitzel 4y agoPHP learned the lessons of the Python 2/3 transition and is making backwards compatibility breaks much more carefully. “fundamental breaking changes […] often” seems like an exaggeration to me. PHP 7 made a few big and necessary changes but they generally did not affect well-written code much. Python 3 broke a lot of things without good justifications, and without a way to make your code compatible with Python 2 at the same time.
- hakre 4y agoI remember one breaking syntax change in PHP 7 a larger project was affected and it was tested with grep and fixed with sed in a matter of minutes. There is benefit if you have the project under test and can run the build with different php versions thought. Best in parallel so you have current, next and future. It perhaps becomes the norm since the yearly release cycle but always was a requirement when supporting different php versions.
- mgkimsal 4y agoCan you give some specific examples? I can't think of too many 'fundamental breaking changes' in PHP between major versions. Some things that will be changed in 9 are now deprecated in 8.2. PHP has gone through a few changes. PHP 3->4 was a moderately big change under the hood, and introduced a lot of new things, but most 3 'worked' under 4 (but was... awkward). PHP 4->5 - a few 'big' things changed - XML processing changed - I had to use some shims to get some projects upgraded. PHP 5->7 - my recollection, and that of most colleagues, is that this was pretty painless for most projects. I can't recall too many major breaking changes, but it was mostly just getting a doubling of speed without any substantive changes. The PHP community has a couple decades of 'major version changes' to look at to learn from. I still can't say I agree with 100% of the decisions, but it's still progressing nicely.
- josefresco 4y ago> PHP 8.2 is a major update of the PHP language. Major update, awesome. /s As someone who manages a network of 250+ WordPress websites - these PHP updates are killing me! As soon as I'm done helping clients upgrade/fix their incompatible themes/plugins and custom code, a new version is out! Even with great tools, the process for about 10% of my network is a nightmare. While I appreciate the work, it's not very satisfying and for many clients very frustrating to pay for something they know nothing about, just to "keep the lights on".
- dncornholio 4y agoYou're doing something wrong. WordPress isn't PHP 8 ready yet. Keep that stuff running on 7.4 and you will have had no problems. Plugins and themes don't move as fast.. Also not a PHP problem but a WordPress problem. It's not a healthy eco-system.
- cies 4y ago> It's not a healthy eco-system. I'd argue that's true for all of PHP. Sure it got better, but compared to other langugaes it is still a mess.
- notresidenter 4y agoPlease provide arguments to support your claim.
- dncornholio 4y agoDisagree, composer exists, namespaces exist, autoloading exists. Enough quality frameworks. I hope you can give some factual arguments why it's still a mess.
- JodieBenitez 4y agoI think GP was not talking about PHP ecosystem in general but about Wordpress ecosystem in particular. And I largely support this claim.
- revskill 4y agoWhat's the standard way to install php, by using `brew install php` ? Is there a version manager for php itself to have multiple versions of php in the system ?
- sbarre 4y agoSince PHP is typically invoked as a web server module or SAPI, you can install as many versions as you want and which one you use comes down to the version you've configured in your web server. You _can_ use PHP from the command line but it's not the same kind of thing as Python or other languages where you need to be mindful of which version some shell script might assume is installed, etc..
- adlpz 4y agoI don't believe there's a specific way to install or manage it. Use the facilities your host OS provides just as you'd do with Ruby, Python or Perl. As per how to select versions easily, the Symfony project provides a Symfony CLI and one of the features it provides is checking for a `.php-version` file in the current directory and selecting the correct php binary from the PATH accordingly. I use that when I'm dealing with projects on different versions.
- mieko 4y ago> Use the facilities your host OS provides just as you'd do with Ruby, Python or Perl. Well that's the thing: I don't know anyone who actively develops in Ruby, Python, Perl or Node that uses the OS-packaged runtimes. The system packages and the language-specific package managers live in different universes. I've seen this situation blamed on both OS packagers or language ecosystems, but now I just think the goals between the two just are fundamentally at odds.
- denton-scratch 4y ago> I've seen this situation blamed on both OS packagers or language ecosystems, but now I just think the goals between the two just are fundamentally at odds. I hate language-specific package managers. I can see their value to packagers (less work), but they end up arguing with the platform package manager. It's like there's a load of CS graduates churning out lots of new, better languages; but what's really needed is just one better language. Similarly we have a score of new package managers, creating incompatibilities; so we add some more package managers, to paper over the incompatibilities. I'm inclined to the view that perhaps there are too many coders in the world, creating compilers and package managers because they can't get a job doing something useful. https://www.reddit.com/r/linux/comments/nnxng/petition_lennart_poettering_stop_writing_useless/ https://www.reddit.com/r/linux/comments/nnxng/petition_lenna...
- jjice 4y agoI write PHP every day and I don't mind the language at all. It's not exciting per-say, but it's a good tool for the job. My real complaint is about how it's served via Apache and my real problem there is that Apache just depends on a lot of things being in the right place and it can suck for updates since it's harder to keep all things config in your repo. Docker is probably a fix for that, but there's an internal political battle there that I'd rather not touch. I know this is contradictory to what some people love about PHP, but having a directory where everything is isolated and I just run npm start or my go binary or whatever is much easier to reason about for me, rather than also have to think about Apache's end.
- larsnystrom 4y agoI also write PHP every day, and the solution I've landed in is, as you suggest, Docker. With Docker and docker-compose you can put Apache config, MySQL data, etc, in your working directory which makes moving/backing up your project a lot easier. There is however a significant overhead to Docker. Building images takes time (and you will need to build your own, if you rely on any kind of PHP extension such as mbstring, etc) and just wrapping your head around everything is harder than people make it out to be. That being said, I used to have my own set of bash scripts to setup local virtual hosts, databases, etc, and various strategies to keep configuration contained to single projects, but things always leaked out of the boxes I tried to put it in and in the end all those strategies failed. So, my current estimate is that Docker doesn't save me much time, but it elevates the quality of the projects I'm working on. So overall I find it worth it to put in the effort to use Docker.
- abujazar 4y agoApache doesn’t need to be in the loop. You can run php-fpm directly behind a load balancer that supports fastcgi, like haproxy. And for depvelopment you can simply use the built in server.
- conradfr 4y agoWhy not nginx with php-fpm? That won't really solve having config files at different places though.
- 4y ago
- cehrlich 4y agoI need to use PHP at work sometimes. After working in it for a while I still don't love the language and would never pick it for a project myself, but it's overall decent a few quirks aside, and I think a lot of people have built up a habit of disparaging it without actually knowing much about it. That being said, one issue I've found is that while I can use VSCode for every other language, using PHP feels terrible if I'm not using a JetBrains IDE. I tried installing the PHP extension pack, but it was still leagues behind. Is there any guide someone can recommend for making PHP a first-class language in VSCode, or am I stuck in phpStorm?
- sneak 4y ago> I think a lot of people have built up a habit of disparaging it without actually knowing much about it. It's possible that PHP's ubiquity and the core language's poor architecture/design (for decades now) are the source, not the ignorance of those complaining. PHP was the very first programming language I learned, in 1997. If anything, I mostly stopped disparaging it because I simply moved on in my career enough to be able to choose languages that aren't constantly fighting me. I'm a consultant so I get asked about unfucking PHP codebases every few years, and I check in on the ecosystem and language. It's better but (unsurprisingly) still not great. Meanwhile, languages a decade+ younger avoided PHP's mistakes.
- deleted 4y ago[deleted]
- synergy20 4y agoI never got it why PHP kept getting bashed even nowadays, it's still the No.1 language for server side web building, Wordpress's market share alone eclipses all its "competitors" such as Nodejs and Django and Flask etc combined then times 100. It's just like the Rust folks never miss any chance to bash C++, while C++'s market share keeps rising and after 16 years since Rust was created, it can not even make 1% of the market while C++ is 12%(excluding C which is 16%,again it keeps rising). Rust's goal by the way should just replace Ada for specific areas, to take on C++ on a broader level it probably needs another few decades, if it can ever make it that is.
- sneak 4y agoI think it is a mistake to conflate the success of the Wordpress ecosystem (and its plugins) with the success of PHP. Just because Wordpress is popular as a CMS does not mean that the developers of Wordpress plugins would choose PHP otherwise. It's also not a contest? I'm not sure why people care about these numbers. PHP keeps getting bashed because it's a bad programming language full of footguns, then and now, regardless of whether or not other programming languages exist.
- cute_boi 4y ago"16 years since Rust was created"? how is it 16 years when Rust 1.0 was released in 2015?
- stevefan1999 4y ago
- deleted 4y ago[deleted]
- pocketsand 4y ago8.2 is going to be a stopping point for a lot of projects that rely upon older code that has dynamic properties in classes. It's not a particularly hard fix but I imagine it people will quickly end up in fork/private repo hell as people throw explicit properties on old libraries and cross their fingers.
- jesuspiece 4y agoPeople still use PHP? Let this horrible language die already. It's banned internally at AMZN for a reason
- efficax 4y agoPHP has been pretty good for a long time now. PHP 7 was released in 2015. It's a vibrant and living language that now has a very nice type system and a super-fast JIT. Most of what people hate about PHP is from PHP 4, even 5.6 was pretty solid. Let this horrible meme that PHP sucks die.
- jesuspiece 4y agoIt's not a meme, it's backed by empirical data. It's banned for security reasons internally at AMZN, not without due diligence
- tonyjstark 4y agoIs C banned then too? And the use of npm?
- efficax 4y agoagain, there were definitely huge problems with PHP prior to 5.6 and 7, but the flaws in the language that made it a security nightmare have been gone for about 10 years (at least). Now the main problem is that it's still used as a dynamically typed language with some type coercion and juggling that can lead to unexpected behavior. But you can use strict_types! With strict types, PHP 8+ is a very nice language.
- megous 4y agoYou say it like some internal decision of some unnamed nobody at "AMZN" is some standard of excellence, or whatever.
- jesuspiece 4y agomore like the entirety of the company (Amazon + AWS) following the guidance of an unnamed "nobody" is, in fact, a standard of excellence :) I challenge you to find PHP deployed in production in any Amazon service
- didip 4y agoPHP seems better now, but what would be the reason to choose PHP when Go, Rust, and Elixir already exist?
- wg0 4y agoI think PHP is getting better but... For any greenfield project, I'll not pick it. Also, I'll not pick any of the interpreted languages for that matter and would want Golang/Crystal/Nim to get single binary to be packaged. But of course - this isn't necessarily something everyone would do. There are no right or wrong answers here I suppose.
- tiffanyh 4y agoCurious, what kind greenfield projects do you work on? Web or something else? I ask because I haven't heard many using Crystal/Nim for web.
- college_physics 4y agothe curious thing with php is that while some very notable and impactful projects are using it (besides wordpress you have things like wikipedia powered by mediawiki, nextcloud, moodle etc) somehow this has not translated into creating much press for the ecosystem as a whole nor a sense that its heading somewhere and carving its own valuable niche there is symphony/laravel as web frameworks, which by all accounts are modern and highly usable, but that in itself doesn't distinguish php given how many alternatives exist
- conductr 4y ago> nor a sense that its heading somewhere and carving its own valuable niche The major niche has been carved long ago. Low cost code for budget conscience clients. PHP has long been the easiest on-ramp to webdev for many folks and some of the things out of it Wordpress specifically, can be utilized to cover a vast number of rather low complexity needs. If you consult with budget conscience clients, you likely find PHP indispensable. If you (or your employer) are building your own software product, you care more about DX and such and have chosen something else. In both scenarios, the end users of the product do not give a damn what it was built with.