18 ms·
PHP in 2023
- dmitriid 4y agoI used PHP in mid-2000s, and then again in ~2017. By 2017, with the power of IDEA/WebStorm at my hands, it felt pretty much like developing a Java or a C# application: the stuff you needed was there, at your fingertips. And I still prefer PHP docs over pretty much any other language doc.
- bluetomcat 4y agoAs of PHP 5, it lost its way and started imitating the Java OO model with a worse botched-on syntax. PHP 4 used to be a compact "hypertext preprocessor" with many built-in groups of functions, enabling you to process forms, talk to databases or process images without much code.
- ceejayoz 4y agoThose functions are all still there. You can still do <?php echo “Hello world!” ?> if you like.
- zeptonix 4y ago<? mysql_connect(...) ?> isn't doing too well
- ceejayoz 4y agoIf you wanna hang your hat on that, go for it. The hacky approach the parent poster yearns for is still entirely possible, even if you have to update a half-dozen lines of mysql_connect to mysqli_connect.
- tehbeard 4y agoIt's a pretty dumb argument to make on the basis that no functionality was lost (There is both the MySQLi extension, and the more general PDO one), and if you really, really can't get the budget to refactor it, you can drop a single shim file in to "get those functions back" while using either of the mentioned extensions to do the actual work.
- dmitriid 4y agomysql_connect has been heavily discouraged for at least 15 years now.
- chippiewill 4y agoPHP 4.1 came out with mysqli in 2001. So you could argue that mysql_ functions have been bad practice for over 20.
- dmitriid 4y agoThis made me realize how ild I am :) Weren't the 90s just 10 years ago?
- esskay 4y agoHow has PHP lost its way? It grew up from a poorly thought out hacky scripting language to a major programming language. All the nasty code you could write in PHP 4 or 5 is still possible, but everyone will look at your code and laugh.
- bluetomcat 4y agoThere are many other possible directions the language could have evolved in since then. For example, an emphasis on its dynamism and statelessness rather than introducing a static Java-like OO model for building hierarchies of classes. Or a modular system that encourages the user to put “complex” code in C modules, making application development as simple as calling a few functions.
- danjac 4y agoMaybe because there are already major programming languages at that level already, which arguably do things better: if you are going to have a Java-like OO model, then just use Java (and leverage its ecosystem, tooling etc). Whereas there is a niche for a quick-and-dirty scripting language for just getting something up and running.
- tehbeard 4y ago... You can still hacky script in it, my dude. I have to do that several times a year for stuff like one-off ETL's for customer data, or to verify an idea before rewriting it properly.. Absolutely nothing about modern PHP stops you from writing like the crayon-muncher you were back in the early 2000's... You just also have the option, to, you know, use battle tested libraries and work with cohesive community driven standards now as well.
- esskay 4y agoIf you honestly think Java is the solution to replace PHP you clearly know very little about the language and its usage.
- cbsjjxhcc 4y agoPoorly thought out? Only the language that runs most of the internet and invented the term tight development loop. All the modern crap has just moved us further away from this.
- cbeach 4y agoI used PHP in my university days, 20 years ago, and went on to build a few websites with it that I still run today e.g. https://caption.me https://caption.me It was a fantastic student language - the docs were great, the code was simple and imperative, there was loads of prior art online. It was empowering to tweak code and see immediate results in the browser. These days I prefer the strictness and ecosystem of Scala on the back-end, and the developer-friendliness of ReactJS on the front-end. And I think the separation of concerns (model-view-controller) is helpful. So I am gradually migrating caption.me PHP code to Scala/ReactJS. A migration like this can be done piece by piece. After implementing the back-end for a feature in Scala, I write the ReactJS component, then alter the PHP code to render the ReactJS component tag in place of the former PHP implementation, then use some simple javascript plumbing for the React DOM binding. I have a Grafana chart that shows the number of lines of PHP code remaining, so I can track my progress over time. It's quite satisfying.
- denysonique 4y agoIf you are the sole developer working on migrating the project and you want to have the frontend in React.js why not use Node.js/TypeScript instead of Scala for the backend? This would save you from context switching between two languages and consequently increase the development speed. Also why the rewrite? If it works (in PHP) it works. Perhaps instead you could maybe add some frontend JS for better caption UI/UX? Does everything have to be done in React nowadays, as opposed to plain static HTML? (Speaking as a React/Node dev myself)
- cbeach 4y agoI tried Node.js on the backend but it didn't have the expressiveness and ecosystem of Scala. I run a few simple Node and Python apps behind the scenes of caption.me, but for the core code, I want the power of Scala, its functional style, rich type system, monadic composition, immutability-by-default, avoidance of nulls etc. As well as great libraries like http4s, Doobie etc, Scala also gives me access to the entire Java ecosystem. The PHP->Scala/ReactJS rewrite is partly a learning and experimentation project for me. I use Scala in my day job, and when I make technical/architectural decisions, I benefit a lot from the stuff I've learnt in my side projects, particularly on the front end side. PHP has had its day in the sun (as shown in the job market trends on https://www.itjobswatch.co.uk/jobs/uk/php.do https://www.itjobswatch.co.uk/jobs/uk/php.do ), so I think it's more valuable to get exposure to modern languages as I still have a few years of professional coding ahead of me :-)
- lemper 4y agoused php in 2015, decided that it's not that nice. last couple of months, I've been banging my head with php7. granted, it's a legacy project, but it is still the same php 7-8 years ago.
- dmoustache 4y agoIt is and it isn't. PHP 8.0 and 8.1 are a different beast altogether in my opinion and way better.
- unity1001 4y agoPHP is what you want to be when you configure it to be what you want it to be. From the strictest language to the loosest.
- esskay 4y agoIf you're inherited a legacy project thats a mess then the chances are it was written by some ass who's not following the languages generally accepted PSR standards. Proper PHP code is extremely easy to dive into and maintain. The benefit and downside of the PSR standards is they are optional. Sadly some think they know better and opt to roll their own convoluted 'standards' that just end up creating hell for the next person to come along and have to maintain their mess.
- cbsjjxhcc 4y agoPSR isn't generally accepted. It's a bunch of nobody know-it-alls that decided everyone needs to write java in PHP. No thank you.
- ianhawes 4y agoYou're just wrong. PSRs are widely accepted and all serious frameworks and PHP libraries implement them as needed. I haven't seen a PHP package in quite a long time that didn't implement PSR-4.
- 4y ago
- Wulfheart 4y ago[dead]
- iLoveOncall 4y agoWhat's the point? You can use types in the vast majority of places in PHP and it works well, so I don't really see the point of that instead of contributing to the native typing system.
- krapp 4y agoJavascript already set the precedent. If you don't like the way a language works, it's preferable to have a proxy language that does work the way you want that compiles to it, rather than accept the language for what it is and learn to work with it.
- 867-5309 4y agowhat do you suggest to achieve this? electron?
- 867-5309 4y agojust a downvote then. helpful.
- iLoveOncall 4y agoYou missed my point: PHP is adding types to the core language, so instead of developing a superset, contribute to the type system of PHP. The comparison just isn't relevant.
- 0x073 4y agoJavascript can't be compared with PHP, javascript is the only scripting language that all browsers understand except wasm. And there are multiple interpreters that may work different or have not all features avail. PHP is used on servers that can run many different languages. Additional there is only one php interpreter that is widely used (yes there was hhvm and some others ), that means you can rely on all features of this version.
- bluenose69 4y agoThe video from that site (also https://youtu.be/x9bSUo6TGgY https://youtu.be/x9bSUo6TGgY at youtube) is really quite well done. I wish more language comparisons were done in this way, with two speedy minutes in an editor accompanied by taut voiceover. Very impresssive!
- brentroose 4y agoThanks! I'm the author of the post and creator of the video :) Appreciate the kind words.
- BuckyBeaver 4y agoIt is tidy and efficient. One question: Are you saying “docblocks?” I’ve never heard of this. Thanks!
- brentroose 4y agoYeah, doc blocks. It's a name that originated within PHP a long time ago: https://docs.phpdoc.org/guide/guides/docblocks.html https://docs.phpdoc.org/guide/guides/docblocks.html
- BuckyBeaver 4y agoThanks. I haven’t used PHP since 2011 or so.
- aurbano 4y agoPHP was my first language back when I was a teenager in highschool - it all started because I wanted to get some data from users and store it (I just knew basic HTML and CSS back then), when a friend mentioned he used a PHP snippet to send an email from a website. That sounded like magic to me so I bought a book on PHP and my mind was blown by the possibilities. Several websites and years later I had a pretty good understanding of backend/frontend concerns, web security, SQL and databases... although I didn't really bother setting up a local environment so I just tested new stuff "in prod" by dropping the new files directly via FPT! After University I then started working as a software developer doing full stack work (mostly Java & Python backends) and Angular, then React for frontend. In many ways I prefer TypeScript + React in the frontend with a Java/Nodejs + TS GraphQl backend, but I remember the speed with which you could get a website up and running, self contained, with no CI/build/deploy issues and it was the best thing ever to learn really I'm almost curious to see what it'd be like to build a website super professionally now with PHP, but I'm pretty sure it'd feel very similar to typed python or Java
- brentroose 4y agoHey, I'm the author of the post. A while ago I made a video where I built a small but serious hobby project in PHP with Laravel. It was a five hour recording, but I condensed it into a commentated 20-minutes timelapse: https://www.youtube.com/watch?v=mmtVkDh9RGw https://www.youtube.com/watch?v=mmtVkDh9RGw If you don't have the time to watch it, you can also check out the open source code of that project: https://github.com/brendt/aggregate.stitcher.io https://github.com/brendt/aggregate.stitcher.io I still work on it, and I'd say i's a pretty accurate representation of a standard Laravel application.
- samuell 4y agoWhich leads me to start to think if there is a way to make timelapse videos that filter out some of the too quick movements, like windows and dialogs opening ... to make you mostly see how the code grows. App idea perhaps? :)
- 4y ago
- shaicoleman 4y agoIt's been 10 years since "PHP: a fractal of bad design" [1] was written. It's remarkable how the language evolved, and how many of the issues mentioned have been fixed and improved over the last ten years. 1. 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/
- archerx 4y agoIt’s funny because when I think of “fractal of bad design”, Javascript is the first thing that comes to mind. I love Javascript but it makes me ask “why?” a lot.
- dubcanada 4y agoPHP is kind of the same league, a lot of hate comes because some senior employee told a bunch of juniors after years of working in Wordpress that PHP is a garbage language and you should not touch it. "It's cool to hate PHP!" PHP can make absolute garbage, and it can make a elegant product. Just like Javascript can. And same with Python and Ruby and what ever else everyone recommends. It may be a lot harder to make garbage in Rust, but it's possible. PHP has a problem where it gets out of your way, gives you the entire toolbox to build a house. But the problem is which one of the 17 types of hammers do I use to hammer in one of the 104 different types of nails. Where as Ruby, gives you 3 hammers and 4 different nails, and 7 magic nails that appear after you're done hammering.
- awestroke 4y agoJust use typescript
- archerx 4y agoNo.
- azangru 4y agoPhp's inconsistencies in regards to needle vs haystack make me weep. Javascript doesn't have anything remotely like that.
- rukuu001 4y agoI used to describe PHP as the spac filler of the web, holding all the good stuff together. Then I had to pick up a Laravel project and - for me - Laravel alone has resuscitated PHP's reputation.
- vistu 4y agoAbsolutely, writing modern PHP with Laravel as a framework makes the whole language feel totally different compared to just even a few years ago. I do also really like the statelessness of how PHP is ran. At the day job we are using it to serve tens of millions of API's a day, without having any issues concerning stability and/or scalability.
- dkdbejwi383 4y ago> Laravel alone has resuscitated PHP's reputation I honestly don't know if this is supposed to be a good or bad thing.
- rawoke083600 4y agoI love PHP - although it probably only account for about 1/3 of my workload/project. Would love to see a loose-goosey-functional-lisp-like lang of php :)
- giraffe_lady 4y agoYeah now that you mention it I'm surprised there aren't more languages that compile to php. The runtime is actually pretty good.
- coderoffortune 4y agoHi, curious to try new version of PHP. Do you know some good tutorial to setup development environment?
- code_runner 4y agoJust hit up laravel and get building something quick and easy. I’m sure a lot of the laravel core contributors actually have some good advice for general env setup outside laravel as well.
- cbsjjxhcc 4y agoYou can just install PHP and use the built in dev server: php -S localhost:8000 -t ~/my-php-files https://www.php.net/manual/en/features.commandline.webserver.php https://www.php.net/manual/en/features.commandline.webserver...
- ceejayoz 4y agoLaravel comes with Sail, which is a ready-to-go Docker install. Up and running in a couple of minutes if you've got Docker installed already.
- colourgarden 4y agoIf on macOS then Laravel Valet is great - https://laravel.com/docs/9.x/valet https://laravel.com/docs/9.x/valet
- kugelblitz 4y agoSymfony ships with a local web server. Or use some Docker Compose if you want more advanced stuff. https://symfony.com/doc/current/setup/symfony_server.html https://symfony.com/doc/current/setup/symfony_server.html
- tiku 4y agoI don't really keep up with all the new features as it suits me fine. In combination with vue it is so powerfull.
- stemc43 4y agoThese days - I use swoole/openswoole with any PHP project. it brings connection pooling, async, concurrency, event loop, io parallelization and much much more.
- tehbeard 4y agoWhat is, in your opinion, the benefit of that over the "traditional" model of having a web server in front for static assets and fCGI/fpm as the link?
- i386 4y agoJust getting into openswoole myself. Are you using any db pooling with laravel? At the moment I’m solving this with proxysql and MySQL sockets.
- oslac 4y agoWhy would a new project in 2023 choose PHP over anything else (modern Java, Kotlin, C#, etc.)?
- brentroose 4y agoThe rich ecosystem, the amount of developers experienced with it, ease of deployment and maintenance
- zeptonix 4y agoKinda applies to anything (Ruby, Python, Rust, Java, Javascript, ...)
- zeptonix 4y ago...because they don't know any better
- nunodonato 4y agobecause PHP kicks ass :)
- archerx 4y agoWhy would anyone in 2023 use Java or choose to be locked into Microsoft?
- Ducki 4y agoWhy "locked into"? When choosing JavaScript, you're locked into JavaScript (and Ecma International), when choosing Kotlin, you're locked into Kotlin (and Jetbrains). You're always "locked into" the language and its ecosystem, no matter what you choose. I don't find that to be a real argument.
- archerx 4y agoIn the front end you have no choice but in the backend you have all the choice into the world. No you’re not always locked in the backend if you have a decentralized system where each service can be based on a different language but yea, I don’t like Java or Java like languages so I will never use especially one maintained by microsoft.
- zeptonix 4y agoI used to work way back in the day on PHP too, but even though I'm sure this will be downvoted, it's really sad people still take it seriously as a language in 2023. There's nothing remotely elegant about it. It's not expressive or programmatically succinct in the way Ruby is. It's not beautifully well thought-out the way Python is. It's not fast and modern in the way Rust is. It's not elegant or composable or client-side renderable in the way React.*script is. It just brings nothing to the table. It's an ugly hodgepodge borne out of an over-engineered homepage from 28 years ago. Various business interests have kept it afloat, and people who don't know any better keep championing it. I think people do eventually catch up with what's going on though as soon as they personally experience writing anything remotely serious (5-10,000+ LOC) that isn't a simplistic web-app.
- mariusor 4y agoSorry to be dismissive, but elegance, expressiveness or succinctness are not mandatory for "making things". Gatekeeping a programming language on esthetics is quite shallow in my opinion. Ease of use and deployment, breadth, availability, low cost of maintaining, are sometimes more important, and PHP offers plenty of value in these respects. I don't want to work with it, but I will never presume to look down on people that do. PHP has been a cornerstone for a whole generation of programmers and I think the current web-development ecosystem would not be where it is without it.
- zeptonix 4y agoYeah I do agree it was a stepping-stone in many ways.
- nattaylor 4y agoI might be misinterpreting "taken seriously" with utility, but to me it is very valuable that a PHP script can just be dropped on almost any web server and it can start doing stuff, and that alone is reason enough not to not dismiss it.
- zeptonix 4y ago
- impulser_ 4y agoIf you are thinking about building a web application, take a look at Laravel. I not a huge PHP user, but Laravel is always on the top of my list for building web applications. It's the greatest web framework to ever exists, even better than Rails IMHO. The ecosystem around Laravel is really incredible and unlike any other framework. They have libraries for every stage of a web application from taking payments all the way down to server management and hosting. They even have awesome libraries like Inertia which are built for Laravel but can be used with other frameworks. It's the only reason I still stay fresh on my PHP.
- code_runner 4y ago+1 for laravel as well. I joined a php project for a fresh rebuild in laravel and had mostly .net experience. Laravel was great. The documentation is an almost perfect blend of examples and nitty gritty detail. The documentation is almost engaging if you’re coming from other frameworks. I found myself thinking “wow that’s almost no code, what about this feature or that” and the next section would be the exact topic I was wondering about. Had a blast and could learn more php details as I went
- spiderfarmer 4y agoThis is exactly what I told my friends the other day. The writers of the documentation do a terrific job placing themselves in your shoes.
- zeptonix 4y agoJust to offer an alternate opinion for anyone reading -- check out Next.js
- clementai 4y agoNext.js is great but can't compare to Laravel, they are not for the same use case. Laravel comes with an ORM, a job queue, a mail framework... And it can also scaffold a complete auth system for you
- waffl 4y agoWhat really struck me was the statement: "In total, $580,000 was raised in 2022 The Foundation pays 6 developers to work on PHP" which made me realise how easy it is to take for granted the development and maintenance of these open-source languages and ecosystem as a whole. Say what you will about PHP, but we all rest on the shoulders of the incalculable effort that goes into the software we use everyday without thinking twice, and is something I'm very grateful for.
- ceejayoz 4y agoSimilarly, cURL has been maintained by Daniel Stenberg for nearly 30 years. Billions of installs, every major tech company probably uses it... labor of love.
- iLoveOncall 4y agoPHP has always been and will always be my goto language when it comes to personal projects. I don't use it professionally, but it's such a breeze coming back to it whenever I work on my own stuff. And the ecosystem (especially Laravel) is light-years ahead of ANY competition in ANY language in terms of ease of use while still having all the necessary features. It's the only language for which I always read the release notes because it's so exciting to see it become even better as the years go.
- awestroke 4y agoI started my career with PHP. Created my own apps, created client websites etc. Full of footguns, but I didn't know any better. Once I learned more languages, I never used PHP again. I actually started to feel like I'd been fooled into using PHP. Now the small PHP community keeps trying to justify their language choice with articles like these and comments like the ones on this submission. They claim it's a no brainer to use Laravel for new apps, because it has a big ecosystem and good ergonomics, and pretend that this description somehow does not apply to hundreds of other frameworks. They claim that the article A Fractal of Bad Design (which was really cathartic to me when it came out) is out of date, but when I look, all the old footguns are still there, all the problems with the standard library are still there and stdout still writes directly to the browser. The foundations are rotten. Go ahead and use it, I don't care, but stop trying to convince me to use it. And now the downvotes begin. PHP devs hate dissent it seems.
- anonyfox 4y agoseems like 2023 is finally the year to pick up PHP and get that limbo. just kidding, I am getting paid multiple times the salary of PHP devs by shipping JS blobs to Lambda functions that render HTML and have DB calls in between them. Totally different from how PHP works, last but not least because I can have a fancy AWS certification for configuring things instead of FTPing a .htaccess file! sarcasm aside, I really think with cutting edge serverless we are ending up where PHP has been like forever, just with _much_ better tooling and processes compared with FTP-deployments.
- azangru 4y agoWhat are authoritative documentation sources for php these days? For javascript and browser apis, that would probably be mdn.io, and possibly web.dev. Any equivalents for php? php.net/manual looks like it might be it; but it contains numerous comments from years if not decades ago.
- kijin 4y agoThe English version of php.net/manual is the authoritative source. It covers all the features found in the latest version. Just because it contains comments from decades ago doesn't mean that the content itself hasn't been updated for decades.
- jdpedrie 4y agoI learned programming with PHP back in the mid-2000s, and worked professionally with it until about two years ago. I haven't touched it since 7.4 or so, except to help some friends with WordPress sites and such. It might be me getting old and grumpy, but PHP seemed to peak in terms of usability and syntax around 7.2. Lots of the new type syntax in the article is... inscrutable to me. I'm all for strong typing in general, and I don't miss the type coercion and weirdness of PHP, and I'm glad to see it continue to move forward. It's just the syntax. Back when PHP 7 was being discussed, I followed the arguments on the mailing lists closely and was rooting so hard for those advocating adding much more explicit and strict typing, and I remember me and a coworker getting rather upset at the old timers like Zeev who were adamantly opposed (and who mostly lost the fight). I'm only 33, but I've got nearly 20 years history with PHP, and I suppose now I'm the old timer. My last project in PHP was forced by business concerns to support PHP 5.4 through (at the time I left) 7.4. The massive pain required to make that work might have colored my perceptions of the whole situation.
- francislavoie 4y agoMaintaining a legacy project might as well be a different language entirely than building a fresh project with modern PHP. I've been doing both, maintaining and modernizing a 17 year old PHP codebase, while building fresh apps with Laravel. And I would say the language is certainly not the limiting factor, but rather prior decisions causing debt.
- lawgimenez 4y agoStarted my career as a PHP dev, I dislike it so much I migrated to JavaME and Blackberry development. Then to Android. Best decision ever to ditch PHP.
- buttocks 4y agoThe shade cast on Wordpress at the end is the article is a little disappointing. Ok, they’re behind on versions but for many years there was not much progress in PHP. Now PHP is flying and dependent projects are not keeping up. What can the PHP team do to help facilitate?
- francislavoie 4y agoIt's not the PHP internals team's responsibility to prop up a private company (Automattic, who owns WordPress) who are lagging behind on maintaining their product and ecosystem. They're already strapped for resources as it is.
- buttocks 4y agoMaybe not, but Wordpress is arguably one of the main applications that has kept PHP relevant over the years. They could reach out a hand.
- iLoveOncall 4y agoThe fact that WordPress doesn't run on PHP 8.x is honestly the least of WordPress' problems. There are MANY reasons to cast shade on WordPress, it's an absolute pile of garbage from top to bottom. I recently developed a WordPress plugin as a personal project for my blog and it just puts in light how bad this software is, from non-existant documentation (on 10 years old functions?) to practices that were already not recommended in PHP 5. WordPress as a product is great, but WordPress as a technological piece is absolute garbage, made by grossly incompetent developers.
- aidog 4y agoPHP runs a lot of my projects. Always grateful for the effort that goes into it. Deploying is very easy using git. Composer makes it easy to install libraries. For the makers: with these packages you can easily make a nice blog/site with minimal amount of code and files. https://phprouter.com https://phprouter.com (one file router!) https://github.com/EFTEC/BladeOne https://github.com/EFTEC/BladeOne (Laravel Style Blade Templates, but much less files) https://parsedown.org https://parsedown.org (markdown library)
- onnnon 4y agoI agree with the author about the superset, this is how it should be done. The current PHP type system has many weaknesses (e.g. generics, typed collections, etc.) that aren't easily solved, and I don't want to use some static analysis tool that relies on comments to type my code properly.
- cgsmith 4y agoI work in PHP each day. I prefer the Yii2 framework and sometimes use Symfony. For some reason I just can't get into Laravel. I tried but the rapid development speed of Yii2 really is the best for my workflow.
- Fred27 4y agoPHP is useful in the same way that Arduinos are useful. I helps you quickly identify people who don't know what they're doing.
- culebron21 4y agoMy main issue with this report is that it gives all figures without any context: - $500K in the foundation. Is this a lot or not, compared to other foundations? Is this more or less than the previous year/last decade? - 6 developers. Again, what does this figure mean? - "many users still use old versions" -- again, at which % should the community be worried? The only meaningful info I found was the chart showing that after 7.0, its popularity stopped falling (though, the chart should have been rendered as stacked to see the full sum of downloads). Regarding the language, I guess people get their job done with it, but the code in the presentation makes an impression that it's the same hassle as back in 2010 (v 5.3) when I quit using it. (Used it since 1999.)
- mike503 4y agoI miss the simple days. I want a PHP that has no classes (procedural only), stops around 5.6 for its syntax (none of these shorthand things) and fixes some of the needle/haystack and function naming inconsistencies. Just give me strings and arrays and floats/ints. I'll add in named parameters, but I think that's the only new thing I'd want to take. Anyone want to go in with me on that?!
- mike503 4y agoOh and for everything else in the normal PHP world, I tell people to use a framework, and for that framework I tell them to use Laravel. Period. To me it's the jQuery for modern PHP (note: I don't even code using it myself, but I tell people to have their dev team start with it)