17 ms·
Before you call me a troll, know that I worked with PHP for two+ years maintaining both legacy codebases and writing new code with Laravel. My question is: why
by ashton314 6y ago
Before you call me a troll, know that I worked with PHP for two+ years maintaining both legacy codebases and writing new code with Laravel.
My question is: why would anyone want to start something new with PHP in 2021? Is there anything that it does better than any other language/ecosystem? I feel like the community is full of (but not exclusively composed of—there are some gems like Caleb Porzio who write good stuff) people who just care about hacking something together and, as long as it works, it's fine. They care nothing about elegance and have but a dim conception of larger CS/SE principles.
For example, why would you write something in PHP when you've got an excellent choice between Ruby/Rails or Elixir/Phoenix/LiveView, both of which are fantastic, and, especially in the case of the Elixir/Phoenix stack, really developer friendly, easy to set up and deploy, etc. and also have solid foundations?
I'm glad to see PHP getting better—it will certainly improve life for those maintaining old PHP projects that are agile enough to upgrade—but I really see no reason to not choose a better tool in this day and age.
(You may now call me a troll if you see fit. I stand by what I said though. :-)
- 55555 6y agoPHP is often a good business decision because there is no shortage of affordable devs to help manage the code. If you're building a small, low-margin business, it may be the best choice. I hate writing PHP btw.
- solraph 6y agoFor lost cost Wordpress stuff sure, but for higher end senior type work I think it's worse than other languages. While this is obviously location dependent, over the last year or so I've had dozens of calls from recruiters asking me to come work on PHP (mostly Symfony and Laravel) applications, and telling me they just can't find competent senior and lead devs.
- zoover2020 6y agoYep, resonates with me. At the same time, these jobs pay very little compared to other stacks. Go figure why they can't find people :-)
- theshrike79 6y ago> My question is: why would anyone want to start something new with PHP in 2021? Same reason as any, familiarity. Not all people, even in software, enjoy learning new stuff. PHP might be the only language they ever learned and it has paid their bills for over a decade. No point in learning anything new unless it's absolutely required. As long as major pieces of software are written in PHP, those people will have a steady job.
- jalfresi 6y ago- shared nothing architecture - single threaded code execution context - copy files deploy I was a PHP developer for over 15 years and those three concepts do more to lower the barrier to entry than any other language I’ve come across, and are constantly underestimated in their power to enable developers to concentrate on the business logic of their program.
- theshrike79 6y agoIndeed, there's nothing like just logging in to a linux box you got access at school or pay $1/mo for and typing 'nano public_html/index.php' - stuff Just Works. Trying to get a python/ruby framework working in the same env, without root access? Whoooo boy. 20 years in the business and I still refuse to do that crap. FastCGI and the like just never work properly the first time in shared hosting. You need virtual environments to keep dependencies at bay, debugging is a pain if the web server and fcgi process don't communicate properly. Most likely you won't have access to error.log so good luck figuring out why everything returns HTTP 500. While you're still figuring out how to get helloworld.py to respond, the dude with PHP is already done.
- joelbluminator 6y agoidk if we're talking about ease of getting started Heroku kinda made it as easy as it can get (started with Ruby but now supports all languages).
- 6y ago
- ksec 6y agoThe first comment in this thread already answered your question. >I would say that Laravel is an extremely high quality framework (on par with and even in some ways better than Rails) that nobody should be ashamed to use. And add to that PHP both a language and its VM get way more improvement than Ruby.
- TylerE 6y agoThat's not really a rebuttal though. He asked why it's better, not the same as.
- joelbluminator 6y agoHow do you measure this improvement compared to Ruby? At least in Ruby/Rails case it's backed by Shopify, which isn't very far from being as big as Oracle (market cap wise). Shopify invests heavily into Rails and in Ruby. Other big companies are Stripe (Ruby only), Github etc. But Shopify is the big deal since it's becoming a FAANG stock as of late. Now for sure PHP has a big following, good companies based on it (though Facebook kinda forked away from it afaik) and people contributing to it but I wouldn't be so quick to say it's improving better or faster.
- ksec 6y ago>At least in Ruby/Rails case it's backed by Shopify, Recently backed. Backed in the sense as investment into it. Ruby and Rails now finally have capital behind it for investment. Ruby JIT being worked on specifically designed for Rails from Shopify, running on Master with better QA etc. But they are comparatively recent. Most of these improvement will take time. PHP on the other hadn't are already seeing those improvement today. And they were work that has been going on for past 4 - 5 years. So in that sense it is improving faster.
- chipotle_coyote 6y ago> My question is: why would anyone want to start something new with PHP in 2021? Is there anything that it does better than any other language/ecosystem? Well, on Twitter the other day, I asked, only partly tongue-in-cheek: > Even in 2021, any new server-side web app with even a vain hope of being installed by people who are tech savvy but not modern web nerds should probably still be written in PHP. True or false? The "false" responses cited things like "it doesn’t matter what you write it in as long as it runs cleanly in a Docker container" and "Node is widespread enough I think it goes beyond 'modern web nerd' at this point," and they might be right -- but I'm not certain they are. So, I guess I'd suggest that maybe the answer to your first question ("why start something new with PHP in 2021") doesn't actually depend on getting an unqualified "yes" answer to your second question ("is there anything it does better"). If I was starting a project that I wanted to have installed by the kinds of people who will not use the word "deploy" instead of "install," if you take my meaning, then I'd at least seriously entertain whether it should be in PHP. Now, for the kinds of projects I think get talked about on HN (e.g., actual paid jobs), this is more of a fair question. I appreciate Laravel and Symfony, but PHP in 2021 has traded the feeling of being a cargo cult version of Perl for the feeling of being a cargo cult version of Java. If I do write a new project in PHP, it's probably not going to be with any existing framework, because even the lightest one feels like endless mazes of "get a Request object from a RequestFactory by instantiating a dependency injection container and passing it to a RequestFactoryFactory".
- porker 6y ago> I appreciate Laravel and Symfony, but PHP in 2021 has traded the feeling of being a cargo cult version of Perl for the feeling of being a cargo cult version of Java. As a Symfony dev I agree. And the process to convert PHP into a Java-esqe Kotlin-esque language is continuing. Why not use a different language if you like it rather than change PHP? > If I do write a new project in PHP, it's probably not going to be with any existing framework, because even the lightest one feels like endless mazes of "get a Request object from a RequestFactory by instantiating a dependency injection container and passing it to a RequestFactoryFactory". I'll be interested to hear what you come up with. Two anecdotes: 1. I had to touch some PHP code I wrote many years ago based on the ColdFusion "Fusebox" architecture. It's missing some nice abstractions but unlike Symfony et al there was so little code I could understand what every line did within minutes. Parts of Symfony's internals are still magic to me (complicated by compiler passes). 2. I was asked to look at replacing a decade-old internal PHP app, the kind people look down on built using jQuery UI AJAX-powered datagrids and raw PHP. There were multiple problems like SQL injection but the app responded incredibly fast. I had to warn them that the replacement would feel slower unless they drastically increased the hosting, because a modern, engineered framework would've only finished booting up by the time this one was returning data.
- jfrunyon 6y agoThe things you mentioned in your second paragraph are precisely why. Because there is no shortage of "devs" who took a month-long training course and think they know everything there is to know about PHP, who will get the thing you're paying them to do mostly working in reasonable time. More importantly, they'll accept crap pay to do it.
- rlv-dan 6y agoI was recently asked to do a simple order page for a company where I know a guy. It would be a simple page with a few web forms, emailing the order to them. That's all they needed. I chose PHP because: 1. Even though I haven't used it in a while it is super simple to get in to. 2. They did not pay me to learn new stuff. They did not need a fancy web framework. They don't care about code elegance. 3. They already had a web site hosted on server with PHP. 4. Development environment is easy to setup locally (just download a portable PHP dev env and run). Everything is built in. 5. Passing it on to them, it's just a few text files to upload that they can easily modify as needed. Nothing to compile. In short, it's just the simplest way to do it sometimes (KISS). And not all projects are big enough to justify more complex solutions.
- angrais 6y agoSounds like (3) is the only strong argument for using PHP in this case. In particular, as a developer you should care about elegance (2), and python (flask) could have solved all other points as easy had they not already been using PHP.
- anonymoushn 6y agoSo, one reason to use PHP instead of Ruby is that you will need 100x fewer servers. When you need 100x fewer servers you might also need 100% fewer devops people.
- cutler 6y agoCare to back that up or are you just trolling?
- deleted 6y ago[deleted]
- simion314 6y agoThere are many reasons to use PHP: - you have already a dev team that are good PHP developers, it is stupid to switch to Python or Ruby , you lose their experience and any chance of reusing existing PHp code you have. The dev team probably knows JS so node might be an option. - maybe you want to build something super simple, like some third party needs to send you a notification event and you want to record that event with other third party API. You can do this with one PHP file , one a super cheap hosting , with code that is simple and clear. IMO all the dynamic backed languages are at the same level, so if you are experienced in PHP environment there is not enough compelling reason to erase this advantage to start from scratch with Python, Ruby or node.
- zozbot234 6y ago> You can do this with one PHP file , one a super cheap hosting , with code that is simple and clear. This. PHP is basically Functions-as-a-Service over commoditized virtual hosting. Maybe we need a toolchain that can transpile down to PHP, starting from more common languages with better development workflow.
- lnenad 6y agoYou can also do it in one golang file. Or one python file. Or one nodejs file. With PHP you have more moving parts, Apache/Nginx with their configuration and then the PHP script. With golang/rust/python/nodejs you have direct access to the webserver and more control, but the same simplicity.
- rytis 6y agoFor development you don't need apache/nginx: https://www.php.net/manual/en/features.commandline.webserver.php https://www.php.net/manual/en/features.commandline.webserver...
- simion314 6y ago>With PHP you have more moving parts, Apache/Nginx with their configuration and then the PHP script. With golang/rust/python/nodejs you have direct access to the webserver and more control, but the same simplicity. From my limited node experience I had to setup Nginx too and then connect it with node, and setup some manager like "pm" to keep the things running. When people say PHP is simple to setup they mean the customer buys some web hosting, and then puts the files there (at most you setup the db credentails and table names ). The customer will not need to hire a sys-admin that will have to use latest docker stuff or try to fix the issue that your customers runs RedHat but the developer wants to use X npm package but X needs some new npm and node version and now the sysadmin needs to make it somehow work. I am not saying PHP is superior, if you are expert in Java, .Net, Python etc continue using that if it makes sense, in reverse if you (your team) are PHP experts then it is a waste to not exploit that experience. You might say that you should fire the good PHP developers that worked for you for years and take a chance on finding some CoolLang experts, from my experience is not easy to find good developers(in all dimensions not only good at reciting best practices), developers that you know that will not leave after 1 year because they want to work on new shit, developers that like to do their job for the end product , for the customer satisfaction and not just like to code because the language is cool, the framework is popular, the IDE colors are shiny and for the CV. If you have a good developer or team , use it.
- lelanthran 6y ago> They care nothing about elegance and have but a dim conception of larger CS/SE principles. Elegance and CS/SE principles don't usually have a business case. Given a choice between PHP and Python for a web-service, there's no practical real-world difference between the two, except that it's slightly cheaper and faster to get your PHP service up.
- cblconfederate 6y agoPlease do not. I wouldn't like the next version of php to become hip and force me to learn kubernetes and a myriad more technologies just to run my app from 12 years ago. Keep php unsexy.
- fraktl 6y agoReasons why to use PHP: - You know how to use it (syntax, what it can do etc.) - You've learned its ecosystem, package management, standards - You can achieve results using PHP and complete projects while adhering to deadlines Ruby doesn't offer anything substantial that would justify the switch. I'm all for developers honing their skills, but business does not exist to cater to developer's whims. Business exists to provide value to clients and put food on employee's table. Being nitpicky about the language and doing language swap is very expensive, especially when you swap language A with language B and gain literally nothing. For smaller businesses or one man shows, it's trivial to start a new project and use a different language. I've seen fair share of superficial analysis and loud comments made by people who are not engineers, judging by their behavior. Like any language, PHP can be misused; and often is misused. It became a rite of passage to belittle PHP. Reading or hearing comments that attack certain technology without objective reasons merely means the person doing it is toxic and should be avoided in general. I dislike plenty of things in PHP / Python / Golang, but I would never dream of whining about it; instead, I try to reach out to maintainers and make suggestions to help make improvements. Having written a few things, here's why you PHP is still appealing (this does not mean other languages cannot do this): - it's sufficiently fast for CRUD-y applications. Bottleneck is usually I/O, but scaling horizontally is not an issue anymore, therefore performance doesn't have to be an issue. - it's feature rich, type system received massive improvements and continues to improve - it has more than 1 framework to choose from (Symfony, Laravel, CodeIgniter, Phalcon, Aphiria, Yii, Zend Framework and the list goes on) - there's an async framework available, called swoole. It's an extension to PHP written in C++ and it brings async capabilities to the play. It's sufficiently quick and allows for building different types of applications: like web socket server or communication-oriented servers. - new Foreign Functions Interface allows for experienced / polyglot developers to extend their apps in an easier manner opposed to writing extensions in C With technologies like containerization, it became trivial to distribute PHP applications and avoid long setup times and reading the manuals on how to make something work. Not everyone use those technologies, but it's what's available and end result can be that you distribute a container image, which for all intents and purposes, means that you deal with a single "file" (thought I want to get across is that app distribution can be made extremely simple). Question that poses itself is this: what reason is there to move away from PHP? Personal preference - I understand it, and this is what pushed me to try other languages and technologies out. If you've got substantial performance, mature ecosystem, plenty of libraries, plenty of frameworks to choose from, great language features, async capabilities and ability to use the language for things other than CRUD-y applications - why use a different language that will ultimately merely let you do the same?
- skrebbel 6y agoThere's a whole industry of "IT professionals" who can't actually write code or do heavy sysadmin, but still can help small businesses with their internet needs. They can drag and drop wordpress/magento files in an FTP client, they can figure out the right plugins to meet the customer's need, and so on. Programmers like to look down on these people but they do great work that makes their customers happy. In fact, I bet they often deliver the same business value faster than the average programmer might. This entire industry wouldn't exist if PHP wasn't so easy to deploy and if there weren't great open source projects such as Wordpress and Magento particularly targeted at that way of working. It's not just "easy deployment", that's underselling PHP. It's "enabling an entire industry to exist" and also "letting small businesses pick a middle ground between hiring super expensive professional programmers or being limited to what Wix/Shopify have out of the box". Wix and Shopify and Webflow and so on are getting better and more powerful, but I'm convinced it's going to take a long time before they replaced PHP in powering the majority of the web. I agree with a sibling comment that Discourse could well have joined the ranks of WordPress and Magento by now, if only they'd chosen the right language.
- pjmlp 6y agoMost ISP support it, and is the cheapest way to get someone on the web without surprises in running costs.
- mrtksn 6y agoWhat if your focus is not on elegance of the code but the product? What if you don't want to spend any time on boilerplate and starter project setup but spend all your time on your idea? What if programming is just the means? What if this is not you: https://twitter.com/cassidoo/status/1216871876192088065 https://twitter.com/cassidoo/status/1216871876192088065 PHP used to be light years ahead in this since it is internet native language. With anything else you have a lot of moving parts that need to be aligned in a specific way to make it work, in PHP the default state is ready to go. How do you deploy your new code to your LAMP server? You put it in a folder. No need for package managers, no need for any other kind of tooling. You even don't need any frameworks beyond your original product requirements. If it's local server, you drag and drop the file you just typed in the code using your file manager. If it's a remote server you use your favourite FTP app. If your idea turns out to be worth its salt you can pay an army of engineers to re-implement it in an elegant way.
- xcambar 6y agoI don't think you're a troll, but I think you know your community well-enough to trick it into a clever karma-hoarding move ;)
- JamesDeepDown 6y agoLook at the abject failure of Discourse. If it had been written in PHP then it would have completely replaced all current forum software. But the devs there hate PHP and went for a modern stack which is all but impossible to install except for tech professionals. In other words, they chose a tech stack which suited them as developers, and not which suited the end users of the software. End users love PHP because you copy the files into a folder. That's why it's so popular. That fact that you are talking about architectural "elegance" shows how removed you are from understanding the needs of the end user.
- joelbluminator 6y agoYou mean simply running Discourse (a Rails app) is so complicated no one wants to do it? And if it was simply PHP boom business would have been booming ? I find that a bit hard to believe.
- open-source-ux 6y agoDevelopers underestimate how difficult it can be to deploy server-side code for web apps or dynamic websites, particularly for less-technically minded users. As other posters have mentioned, PHP code can be as simple as uploading files to a folder on a server using a GUI FTP app. (And for some non-technical users, even that might be too complicated). By the way, Jeff Attwood (co-founder of Stack Overflow and one of the founders of Discourse), had this to say about PHP: "If you want to produce free-as-in-whatever code that runs on virtually every server in the world with zero friction or configuration hassles, PHP is damn near your only option." [1] When did he say this? 2012. It's now 2021 and has anything changed? Not really. Yes, we have Docker, Cloudtron, or Sandstorm etc but none of these are simple or easy to install or use. (A developer's definition of 'simple' and 'easy' bears no relation to the real definitions of these words). Whatever you think of PHP, consider the following question: what language can match or beat PHP for ease of server-side deployment? [1] https://blog.codinghorror.com/the-php-singularity/ https://blog.codinghorror.com/the-php-singularity/
- joelbluminator 6y ago
- salvadormon 6y agoYou can ask the same for any language, not only PHP: - Why would anyone want to start something new with Ruby? - Why would anyone want to start something new with Elixir? You can choose any reason to pick a language, do you want a language with a lot of demand in the job market, learn Javascript, you will see a lot of frontend open positions, even more React open positions if you want to specialize in something. Do you want a lively developer community, choose any language, I learned Java, PHP, Javascript and Ruby and all of them always had helpful people and a lot of courses to help me learn and try to code with good practices. Answering the question seriously (assuming this is not trolling) here are some reasons to start something new with PHP in 2021: 1. Learning PHP 8 and a popular framework like Laravel will make easier to get a job on some small and medium companies. In the last job I had in a consulting firm, customers were asking for more Laravel developers to the point they accepted outsourcing because there was not enough talented Laravel developers in the US to cover the demand. There are thousands of bad PHP and Laravel developers, but there is not enough supply of good ones, so if you are talented and follow best practices, choosing PHP will make you shine between all those average developers. 2. I probably won't develop anything new with PHP 8 this year, but there are a lot of existing libraries and frameworks (Laravel and Symfony for example) that will benefit from implementing the new features of the language (reducing mess or making code more concise and readable). For the end user of those libraries and frameworks, very little will change since the interfaces don't change too much in order to allow backwards compatibility, so the existing ecosystem is a great reason to use PHP.
- cies 6y ago> Ruby It has a very mature web dev ecosystem around Rails. It: is quick-to-learn, is OO to the bone, is FP where is fits with the OO, is easy to read, has little quirks. Personally I'd go with something with stronger types, no "null" and proper sum types. But if you are cool with dynamic typing: Ruby is a great choice. > Elixir Ruby-like syntax (some advantages just mentioned) and BEAM runtime. Yields very scalable apps. I do thing GP raises a valid concern. PHP is not for new apps, or even better put: for new teams. It's just too quirky and does not have the native browser support the other super popular + super quirky language JavaScript has. As as a comparison: who'd start an app in Perl these days? Or COBOL? At some point a language may be considered "legacy".
- Wouter33 6y agoPHP is just very simple and powerful. Check out levels making 100k per month with a single php file: https://twitter.com/levelsio/status/1381709793769979906?s=21 https://twitter.com/levelsio/status/1381709793769979906?s=21
- slver 6y agoI'd love to debate the use of PHP vs. Ruby and Elixir, but your arguments basically are: - The community is full of people who just care about hacking something together. - Ruby/Elixir are fantastic, developer friendly, and have solid foundations. The first happens with every popular scripting platform. Is JS community full of PhDs? The second is highly subjective. Ruby is problematic, because it's supported by one framework which is showing its age, and the language itself has lagged behind in performance, which matters increasingly for web workloads. Elixir is a niche dialect of a niche language (Erlang). Don't get me wrong, Erlang is amazing. But you don't need Erlang to set-up a blog. It seems the major reason going against PHP are: - WordPress and the entire ecosystem around it sucks. Well, sure, but PHP has more frameworks with big mindshare like Symfony. It's not a "Ruby on Rails" situation. - The meme about hating PHP is big. Everyone loves to hate PHP and Basic. Even when Visual Basic .NET evolved to be basically no different than C#, the meme of hating it lived on. Same with PHP. The thing with memes is they're not rational. So fighting them with rational arguments is pointless. If peer approval matters to you, then code PHP in secret or don't code in it. If shipping projects matters more, PHP is a pretty good option for most websites.
- hrktb 6y agoMoving from PHP to ruby, language speed has never happened to be a subject. During coffee time banter, sure, but in real performance related issues, what we face came down to query optimizing, cache management, algorithmic issues and data pre-processing. We didn’t even hit the “let’s write this in C” moment nor debated about moving parts of the code to faster systems/libraries. I’m not saying it will never ever happen, just that ruby’s sheer speed doesn’t seem to have a practical impact other than slightly higher hosting cost perhaps.
- slver 6y agoI'm sure that's the case. But as we break down the arguments that PHP sucks one by one, it's not performance, it's not libraries, it's not this, it's not that. How about this article "PHP a fractal of bad design", oh most of those no longer apply to PHP. What's left? The slightly unwieldy syntax (still C-like, so close enough), and the bad reputation driven by memes.
- conradfr 6y ago> the Elixir/Phoenix stack, really developer friendly I do PHP/Symfony and Elixir/Phoenix and really it's more nuanced than that. Really if I don't need things that are suited for the BEAM/Elixir/Phoenix I'll probably be more productive with PHP/Symfony, especially for CRUD: the strict type system is better, the templating is better, the framework includes way more functionalities, the static analysis is better, PhpStorm with the Symfony plugin is amazing, even the docs are better. But yeah, the app will probably be slower (but probably less than you think nowadays) and coding will be less fun ;)
- gremlinsinc 6y agoI think if you can integrate swoole with coroutines in the right places, some benchmarks may have it faster than phoenix even... and I know laravel has had swoole packages, but recently with octane has made it more central which is good because a lot of issues were with maintaining state with requests and multiple threads as well as database changes.
- k__ 6y agoI started my career in 2006 with PHP and was using it a few years before in private. I used it until 2012. After that I switched to JavaScript and never went back. First, I did frontend development, then backend with Node.js, then Mobile with React-Native. In between games and now serverless. PHP isn't bad, it became quite nice these days. But it simply isn't as flexible as JavaScript. Everything new technology that comes out has JavaScript support right from the bat. If I need static typing, I drop in TypeScript. The performance is also crazy good for a "mere scripting language". If you need more perfomance than JS has to offer, there is only C, C++, and Rust left. Back in the days I used PHP for those exact reasons. It was simple, fast enough, and supported everywhere. Sadly, that isn't the case anymore.
- deergomoo 6y ago> But it simply isn't as flexible as JavaScript I guess it depends how you define "flexible". The language itself is clunkier, particularly anything involving closures (although that's getting better), but it does so, so much stuff out of the box (even if the APIs are often a bit footgun-y).
- Ambix 6y ago> I used it until 2012. That means that you've missed the train of modern PHP and frameworks completely. It's not fair to compare old school PHP with modern lang like TypeScript
- remux 6y agoIt's easy to learn, fast and many people understand the code. And it just work.
- blodkorv 6y agoI use php for my startup and all new things are made in php for these reasons. the ecosystem is very much complete. There is nothing that has not been done and tested in php. Plenty of developers know php and if you have done C#/Java/C++ etc its super easy to learn. Its easy to setup and well documented and the LAMP/LEMP stack is battle tested and people know it well. There is great Editor/IDE support with plenty of options to choose from. You can run it on any kind of developer-os and do you development there then just deploy it to a linux server. Altho docker solves this now with any lang its still nice if you dont want to use solutions like this. I have devs developing on windows, linux and mac with no issues getting the whole development stack running and then deploy the app on linux with no issue. This has been a challange in ruby on rails last time i tired it (back in 2010). The laravel framework is great.
- igammarays 6y agoPHP/Laravel is a higher level of abstraction. With Laravel specifically, it's the closest thing I've seen to writing web-app business logic directly in English. Sure, like any abstraction, it comes at a cost. Your applications would be more performant and CS-theoretically-elegant if written in C++ or Elixir/Phoenix. But you would spend a lot more time digging into segfaults, manipulating databases, and writing CRUD form boilerplate, which is far removed from your business logic. I chose PHP for my recent startup -- despite being less experienced with PHP. The speed of development in Laravel is insane, because most of the framework is focused on making the common features of web apps more convenient. Coupled with static analysis tools and IDE helpers, all of the Laravel magic is actually understood by your IDE (PHPStorm). I've worked with Python and NodeJS for most of my career, and I've never seen this level of dev tooling. My newest project was in Laravel. I was able to ship the whole thing in half of the time it would've taken me in Django or some NodeJS framework, simply because the Laravel "magic" around databases, forms, CRUD, IDE helpers, ORM and scheduling and task queues is so fantastic.
- ashton314 6y ago> Your applications would be more performant and CS-theoretically-elegant if written in C++ or Elixir/Phoenix. But you would spend a lot more time digging into segfaults, manipulating databases, and writing CRUD form boilerplate, which is far removed from your business logic. With C++, absolutely. With Elixir/Phoenix? I never have to debug low-level issues. I also don’t have to waste time debugging stupid scope stuff and dumb data structure inconsistencies that PHP is full of. > “magic” around databases, forms, CRUD, … scheduling and task queues… “The bill comes due…” As long as you’ve got a small scope, sure, that might work. Maintenance on magic gets harder though. If the magic is what you need, you might want to take a closer look at the Phoenix system. Ecto’s DSL is just as easy as an ORM in the simple case, but is far more composable and robust in the complex cases. For simple jobs, you can just leverage the BEAM for task scheduling—I needed a little task run every 5 minutes; all it took was a dozen lines of simple code—no Redis needed! Just as “magic” feeling, but better architected and maintainable in the long-run.
- rgoulter 6y agoI think the points from "Taking PHP Seriously" are still interesting. https://www.infoq.com/presentations/php-history/ https://www.infoq.com/presentations/php-history/ The argument is that PHP's strengths are its workflow, its state, and how you work with concurrency. i.e. PHP's execution model (per-request) allows for things like not having to worry about restarting the server when you're developing the files. The complete lack of shared state between requests means you don't get complex footguns.
- mns 6y agoTo answer the question. It evolved a lot over the last years, it has a thriving community, you will always find answers to your questions, there are a lot of developers and I personally think the community around the core is quite competent at what they're doing with the language. We started one of our biggest projects on PHP 5.6 and Symfony 2.x years ago. The maintenance process and the upgrades were absolutely painless. If you're disciplined, you can probably do this with most of the languages, but we constantly were able to upgrade, so that we are running on PHP 8 now and the latest Symfony version. Of course we had to pull certain parts that started to be too big out of the app, some are now node, some are Symfony, some Java, but the core is running on the latest versions and the evolution of the language and the performance improvements that we had with the upgrades over 9 years are incredible.
- xd 6y ago"They care nothing about elegance and have but a dim conception of larger CS/SE principles." / "I really see no reason to not choose a better tool in this day and age." Every time there is a PHP news update these kind of posts come out. They claim some vague experience in PHP and then go on to list all these other wonderful languages you could be using instead and that insinuate you must be a bit of a shit developer to be using PHP. Unfortunately this troll has been well fed.
- sputr 6y agoEven worse, your parent comment blatantly tries to shame people who focus on the product instead of the tool. Because yeah, I'm using a programming language to CREATE something ... not to, you know ... use a programming language. Moreover, it's also obvious from these kinds of posts that their authors have never thought about the business context at all, otherwise they would have realized that hiring PHP devs is hard enough ... but hiring [insert fancy new language] or even [python/ruby] is next to impossible without spending way, way too much money.
- mgkimsal 6y agoJust spoke with someone who has a (very good) php dev on staff, and has someone else on staff with some node experience, and is partnering with someone else who does rails. They decided on a new project being done in rails because the rails guy said "it's easier to hire rails devs than PHP devs". That is so far off my experience, and I don't mean "php=wordpress therefore you can find loads of devs". I mean that finding good people who can hit the ground running and not be a net drag on a project - in any tech - is, imo, very hard these days, and has been for probably the last 2-3 years at least. Basing mostly on regional network and chatter in user groups, but it definitely seems to have gotten worse recently. "easier to hire good devs in X" doesn't seem like the best metric decide on (but maybe it is?)
- gremlinsinc 6y agoReminds me of the meme/video about mongodb: "It's webscale". https://www.youtube.com/watch?v=b2F-DItXtZs https://www.youtube.com/watch?v=b2F-DItXtZs
- omnimus 6y agoDont forget about content websites. PHP has pretty big dominance in usage and quality of CMSes. And i dont mean just wordpress and drupal (which are pretty meh). Its things like Craft CMS or Kirby CMS. Also open source ecommerce - prestashop/opencart/woocommerce. So if you are devshop doing lot of CMS development and start doing webapps/apis then something like Laravel makes lot of sense.
- krageon 6y agoI've worked with it for a little over a decade and I have to agree with you. It's a lot better than it used to be, it's just not very good. That said, the reason people use it is for it's popularity: It's easy to get into and almost everyone can write it badly. Much like javascript.
- sam_goody 6y agoI have experience with JS (node) and PHP, and between the two I would choose PHP for any real website. I appreciate a lot of things JS gets right (including PNPM vs Composer), but Node is far less reliable and IMO PHP is the better language. My Rails friends all recommend against using Rails for any new projects. I never bothered to get the laundry list, as that is enough to convince me not to learn a new language. I wouldn't use Go or any language that requires compilation. I don't know anyone who uses Elixir, which is enough to keep me away. I worked with Cold Fusion and with Erlang in the past. When I got stuck, finding someone to help me was not fun (with CF I even paid for consulting) and existing libraries were few and incomplete. (Although I enjoyed Erlang as a language). For me, PHP is a go-to language for new projects, and it has become quick enough, stable enough, and complete enough to hit the check boxes I need.
- cutler 6y agoI don't get why your Rails Friends would not recommend it for new projects. Care to elaborate?
- akoncius 6y ago> that I worked with PHP for two+ years maintaining both legacy codebases and writing new code with Laravel. might seem like trolling, but from what I've seen, Laravel encourages bad developer practices such as static code etc, while Symfony encourages good OOP practices. so Laravel in itself is attracting specific audience with different priorities than Symfony, so it may explain your main complaint about PHP code which cannot be treated as same. I mean Laravel is written in PHP but it does not mean that same code practices are used in other frameworks/projects.
- robotron 6y agoAs a PHP developer, this is spot on. I'm biased, though. I believe symfony is a vital component of modern PHP.
- AzzieElbab 6y agoI feel like yelling “die” each time I see “php”, but on the other hand - man, those were simpler times when we were pushing a feature after feature instead of talking about overly engineered architectures and nuances of super complicated runtimes of the current pls
- ransom1538 6y ago"My question is: why would anyone want to start something new with PHP in 2021?" Because that is how people get things done. Example. With Elixir/Phoenix/LiveView I will give you a simple task. Provision a phone number on Twilio. Please see this image: https://imgur.com/a/iACVPvU https://imgur.com/a/iACVPvU What would you end up doing? I would bet wasting a ton of time or hacking something up with curl. With PHP/python/ruby I would be done in 10 minutes.
- conradfr 6y agohttps://github.com/postmates/ex_twilio https://github.com/postmates/ex_twilio Probably the code would not be that much different, or at least not more complicated to write. You would also not use curl anyway with Elixir, it has http clients like other languages you know, for example Httpoison.
- colllectorof 6y ago>For example, why would you write something in PHP when you've got an excellent choice between Ruby/Rails or Elixir/Phoenix/LiveView You can make a simple website on PHP in ~30 lines of code (routing + boilerplate template) with nothing more than a text editor. It will have no dependencies beyond standard PHP modules, so you could then migrate this website to hundreds of cheap shared hosting providers just by copying files via FTP or SCP. It will run fast even on server with crap hardware. There is nothing remotely similar in any other language. All other solutions are less portable, require way more configuration and more infrastructure on the dev side. ... ~15 years ago I made a website for a certain community using PHP. I still maintain it. On my own time, on my own dime. It doesn't cost much, thanks to properties I described above. So it's still operational. Think about that next time you talk about "maintainability" and "stability". ... I'd love to have the same ergonomics of deployment with other languages. You can make it work. Jetty + Apache Velocity, for example, can "feel" similar to PHP. But there are no hundreds of providers who will manage this for you with little to no configuration.
- Shish2k 6y ago> Is there anything that it does better than any other language/ecosystem? It has the lowest barrier to entry, both as a developer, and a user - as far as I can tell no other language has even tried to compete in this area :(
- CaptArmchair 6y ago"If you have a hammer, every problem looks like a nail." Both PHP and the success of Web applications are inextricably tied to each other. It's easy to pick up and easy to run. Others commenters have already expanded on these advantages. PHP has treated the Web as a first citizen before anything else for the longest time. It sits on the crossroads of I/O over HTTP(S) and it's really good at what it does. The massive amounts PHP frameworks are testament to that. Even so, moving away from that vantage point, the story shifts quickly. The rise of the Web doesn't just imply managing / processing HTTP(S) I/O - building a simple web interface, a simple REST/JSON API,... - it also means managing the complexity of data management. Data migrations, transformations, juggling processing jobs, tying API's together,... are the bane of many a PHP developer. Many a PHP framework provide API's to do background processing via PHP scripts you run on the command line. There are plenty of PHP libraries out there to make things easier as well. Thing is, languages like Go or Elixir run circles around PHP when it comes to things like concurrency, multi-threading and robustness. Python's idiomatic approach to data munging makes it more suitable then PHP to deal with complex textual as well as binary datasets. PHP absolutely has it place for several classes of business problems. But definitely not for everything. Having spend a decade in PHP consultancy, I've witnessed several client projects suffer heavy delays or fall through because an entire business domain got shoehorned in PHP, and - worse - in specific PHP frameworks that bring their own additional layers of complex abstraction. The latter is not a fault exclusive to PHP or developers who solely specialize in writing PHP, or even a specific PHP framework. Rather, it's caused by complex biases and social dynamics that tend to lead towards a narrow-minded tool-centric approach of complex business challenges. Just like a hammer, PHP is a tool with a limited set of use cases. Just like any language.
- piokoch 6y agoYou have kind of answered you own question: "people who just care about hacking something together and, as long as it works, it's fine." If you need to hack something fast, deploy it using SCP on a cheap hosting then PHP is a very reasonable choice. The only thing which is needed is Apache PHP module enabled. No need to think about ports, starting some additional server, doing proxies, etc. Registration form? In PHP you just need to open a file, add <? tag, 5 lines and you call database, another 5 to send email with SMTP server and you are done. No need for application generators, templates engines, DB abstraction layers. Fancy functional programing language not needed, basic knowledge of some C-like language suffice to hack something fast. Obviously such application will have maintenance issues, etc. but very often this just does not matter.
- stunt 6y agoWe recently picked PHP for a large web application. The usual choices at our teams are Java11, Golang, and Typescript (+ a few teams that use Kotlin, C# and Rust). Many team members however also had experience with PHP in their career, but the main reason for us to pick PHP was Laravel's ecosystem really. The amount of features and scaffoldings that you get out of the box is just crazy. It gives you proper authentication for both web and APIs with 2FA and everything out of the box. Plus billing integration with recurring billing support and everything you need for payments, and also team management features ready in 5mins. And then you add another package for building administration panels (it's called Laravel Nova) which costs nothing comparing to alternatives for Java and deliveries much better development experience. It has been almost a year and no regrets so far. I think it easily saves you 6 months of development time if you want to build a web app or a website beyond a static page. The ecosystem is very stable and reliable. So why not? I encourage you to watch some of the introduction videos that they produce to show their ecosystem. That's how we were convinced to start investigating it. We spent a couple of weeks to make everyone productive with it. We had to catch up with all PHP7+ features and read Laravel docs. I think we will still build a lot with Java and Golang, but not for WEB. I don't see a better alternative for building web apps or front-end projects. We don't however mention it in our portfolio or even on our job listing. It's apparently not cool for a publicly traded enterprise to say that we also use PHP.
- archer_ 6y agoYou‘re right, it‘s insane what Laravel‘s ecosystem has to offer out of the box. However, most of these features save you lots of development time AND are free to use. What makes me unhappy here is that a company and its employees benefit from these ‚free‘ features and at the same time they don‘t condescend to mention it in their portfolio or even job listing because it‘s not cool enough.
- repox 6y ago> why would anyone want to start something new with PHP in 2021? What can you make in X language than I can't make in PHP? And vice versa? Don't get me wrong, I fully support the "select the right tool for the job", there are obviously better languages and frameworks for different kind of tasks, but let's just consider the context in what PHP is usually used in. I get that people dislike a syntax. I loathe Python, basically because indentation actually controls how and whether your software works and I can't use indentation for organizing the readability of my code. But that doesn't mean that I would ever argue against the use of Python; again - what can you make in Python that I can't make in PHP? And the other way around still. inb4 "But PHP doesn't do async" - [fibers](https://wiki.php.net/rfc/fibers https://wiki.php.net/rfc/fibers) is a start on that journey. We've managed so far.
- robinhood 6y agoThe ecosystem is what makes the huge difference, especially thanks to Laravel. So much documentation everywhere. So many helpful resources. I've tried to learn Rails back in the days (ie 7 years ago) and was shocked by how poor the entire documentation is. I subscribed to Railscast but it hasn't been maintained for years. The PHP ecosystem, however, is incredibly alive.
- milesvp 6y agoWordpress. I haven’t been paying attention for a few years, but last I looked wordpress powered over half of public websites. Wordpress was forced upon my team at my last job because non technical users have been exposed to it and training costs were a big deal for my organization. It wasn’t something I would have preferred for technical reasons but it just sort of makes sense in a lot of contexts where a content management system is required.
- Zelphyr 6y agoYou're right that PHP has historically had its fair share of "development by copy-and-paste from StackOverflow" developers. However, I've noticed that in recent years a lot of those people moved to the JavaScript ecosystem. It's the latest shiny and the learning curve and time-to-deploy curve is low like in PHP (though, many in the JS community are trying their best to complicate that part for reasons I can't fathom) Does that leave a PHP community comprised of only people who adhere to solid CS/SE principles? No, but that doesn't diminish the fact that PHP still has a lot going for it. It's easy to get started. You can adhere to solid CS/SE principles with little effort if you have the discipline to do so. It's trivially easy to deploy a PHP application. The documentation is still fantastic.
- rambojazz 6y agoMaybe that is the experience with Laravel, but I had the opposite experience with Symfony.
- georgesC 6y agoBecause producing tools with php is VERY fast, and it runs almost as fast as a scripting language could. It's simple, and efficient. One of the language that requires the least amount of code to produce a given result. Plus the longevity of the project. The question is why would anyone NOT want to use php in 2021 for non desktop developments? I also prefer pure php, with no frameworks. I think it's best to build your own tool that suits you.