10 ms·
PHP in 2024
- gopalv 2y agoPHP has a special place in the story of the web-dev. The whole "no build step" was the most underrated factor for its success, because it was such a low-skill tool to pick up. The tightness of that edit-test-move loop was why I used it, even if the "edit" included "sftp it to a vhost". That bit is what made it successful & I can't think of anything I've used in the last decade which felt as easy as PHP for that particular style of self-taught programmer.
- supernes 2y agoHot Module Replacement and Live Reload in Node-based web dev servers bring some of that magic feeling back, although you will quickly need to learn about module resolution and other intricacies.
- cabirum 2y agoIt's only easy to start up to hello world kind of projects. To build anything useful you quickly discover that it's hard to build from source (both the lang and extensions), some parts unmaintained for years. There are many counterintuitive idiosyncrasies you must deal with to be productive. The ecosystem suffers from the overuse of indirection and reflection. Php only looks easy, but the rabbits hole goes deeper than most other langs.
- gog 2y agoHow would you describe something useful? Can you give examples of counterintuitive idiosyncrasies you must deal with to be productive?
- deergomoo 2y agoWhy on earth would you need to build PHP or its extensions from source to build a useful web project?
- pjerem 2y ago> It's only easy to start up to hello world kind of projects. Sure but the important part here is it’s also easy to deploy to the internet for free or a few bucks. All you said is right but still, I don’t think there is anything comparable nowadays and if I had to explain to my son how to create a basic non static website without using proprietary PaaS, I’d have a hard time (without PHP). Was it the best option when you were a company building a product ? idk but at least it was a viable option. Was it the best option for any kiddo wanting to learn creating things on the internet ? Totally and we never got anything better for this since PHP.
- pjerem 2y agoI didn’t touch PHP for a long time but it have a nice place in my heart especially for the reasons you gave. I have a hard time with people joking about PHP because while it wasn’t perfect back in the day, it’s probably the culminating point of the non elitist computing. PHP was accessible to anyone who had the basics of creating an HTML website (which was a skill any random person could acquire in a day or two). Also, the people making those jokes are most of the time working on projects with micro services and SPAs everywhere for a boring business app with CRUD and forms. Which I find pretty ironic since a single PHP monolith solved this exact use case 20 years ago.
- kaba0 2y agoAlso, it had dirt-cheap hosting, as a single process could host multiple sites (though it did come with some security implications). Nowadays we tend to bring up a whole virtual OS. An interesting direction in this area might be GraalOS, which might allow running multiple applications in a single OS process, doing the necessary isolation itself. (Not affiliated)
- yashg 2y agoBack in the day when VS Code didn't exist and even sftp was rare and the world ran on port 21 classic FTP, we had code editors with built in FTP like PHPEdit, we would literally hit Ctrl+S and save and upload the file on production in one stroke. Refresh the page in browser on the live site and there it is. Those were the insane days before terms like agile and CI/CD were even invented.
- throwaway11460 2y agoScrum is older than Linux.
- progx 2y agoYes insane and after upload "bang error", sh...t, fast fix the error and upload it quick again, befor anybody register the error :D :D
- aaviator42 2y agoCtrl-Z, Ctrl-Z, Ctrl-Z, Ctrl-S!
- aaviator42 2y agoI still do this! Often still over FTP, sometimes over folder mounted over SSH.
- kijin 2y agoI'm taking the "no build step" thing to the extreme in one of my projects. PHP has libraries for compiling SCSS and minifying JS, and filemtime() is very fast. So if you wire them together in just the right way, you can edit any script or stylesheet under the project hierarchy and have them compiled, minified, and bundled together on the fly. Cache the bundle until you edit one of them files again, and automatically bust the cache once you do. No need to build anything whatsoever, both on the frontend and on the backend. It's like REPL over HTTP.
- todotask 2y ago> PHP has libraries for compiling SCSS and minifying JS, and filemtime() is very fast If you do compiling and minifying, that's a build step.
- wildrhythms 2y agoThe usage of the term 'step' here is in the pre-deployment development process sense. I think what this person is doing is converting SCSS to CSS on request, at runtime.
- todotask 2y agoRegardless of which steo, compilation process is typically done as part of a build step, where the SCSS files are transformed into the final CSS that will be served as a bundle to the end users' application. Web browsers can't understand SCSS natively. To be truly extreme (performance), devs should consider tree-shaking unused CSS and JavaScript. This may require using Vite (Rolldown is in the works/Rollup) if there are no other options or it makes no sense to serve bloated resources. That's the reason, I chose Astro as I care about users, not prioritse the developers' minimalistic workflows. I prefer Tailwind because it allows me to avoid duplicating classes (mine and vendors), which is an advantage over other approaches. I did dogfooding in Go development.
- kijin 2y agoEvery human-readable programming language must be compiled into some sort of bytecode (opcode in PHP) and/or machine language in order to work. The question is whether a human ever needs to be aware of that step. In PHP, you generally don't. In the aforementioned setup, you don't need to be aware of SCSS compilation and minification, either. Not even if you use devtools, because the map file will point to the correct line in the original source.
- Morelesshell 2y agoThis also lead to shitty tool integration. While it was always easy to debug java based apps and the debug support is great (remote connection, drop frames, all types of breakpoints etc.) people struggled with this in php. I showed a professional a few years back how to debug with php, after 2 weeks he stoped using it...
- M95D 2y agoI liked the documentation. The old documentation, in a .chm file.
- xeornet 2y agoHave been using PHP since 2008 and will continue to do so. The community, ease of development and ecosystem around Laravel is unbeatable.
- ainiriand 2y agoLaravel rocks though I am more of a Symfony man myself, been working with it since 2.1. API Platform has no equal. At $job I built a fully DDD system on top of it and its been a breeze.
- notresidenter 2y agoPHP and the ecosystem around it, especially Laravel, makes developers incredibly productive: everything is so damn easy. Nothing comes close to it in Go, Ruby, JS (Node), Python; from what I've seen. Laravel is one step ahead.
- ramon156 2y agoI'd love to see something like laravel/symfony in go/rust. If anyone is willing to give it a shot I would've switched yesterday
- pjerem 2y agoHonestly it’s pretty hard. We are talking about frameworks with decades of development. It’s not something that can be done by one developer, you need corporate levels of investments at least to bootstrap it.
- Klonoar 2y agoWell, no, that's not really a fair assessment. Someone is quite literally doing "rails but for Rust" with loco: https://loco.rs https://loco.rs As far as I know, the bulk of this effort has been one developer pushing it along. I wouldn't personally use it but it _does_ exist. It's also worth noting that these older frameworks all come from a different era of development - nowadays most newer devs seem to want to build microservice-after-microservice, where these don't quite fit into the picture.
- pjerem 2y agoThey are doing it and I hope they succeed and prove me wrong but last time I checked Loco was still far from Rails.
- notresidenter 2y agoI've thought about doing a Laravel-like framework in Go, but one of the superpower of PHP/Laravel _is_ the possibility to have very loose / no types, which gives a great DX when used correctly, but in Go, you'd have to interface{} so many things that the resulting code would be non idiomatic / not as performant as go can be. And then, you'd need to have an ecosystem as strong as Laravel which... wow... would take a _lot_ of investments.
- geek_at 2y agoI was never able to move from PHP to something else. I tried nodejs for a few months but it always seemed much more complicated. Especially the dependency and build system. With PHP to move my code to a production system I just need to run `git pull` and the new codebase is instantly live. No builds, no server updates. The Markup system of PHP is also very very handy. No more messing with handlebars or external libraries. Realistically you can start a small site with PHP and HTMX and no external PHP package dependencies in an evening.
- aaviator42 2y agoI'm in the same boat! PHP is so insanely functional. There are a lot of powerful frameworks but I personally like to keep my projects very simple with minimal dependencies and nothing comes close in terms of how fast I can go from idea → prototype → production. PHP + SQLite is a beast.
- zelphirkalt 2y agoNit: Most code written in PHP is the (an) opposite, of what many people discussion programming languages would call "functional". It is procedural, and maybe object oriented, although important things are missing, like generics/parametric polymorphism.
- seszett 2y agoFunctional here means that it functions well. Not that it's a functional language.
- aaviator42 2y agoIn case it wasn't obvious from the context of the rest of my comment, I was using this dictionary definition of 'functional': > designed to be practical and useful, rather than attractive. It gets the job done. Really well.
- kyriakos 2y agoall he said is that he can get his work done. definition of "functional" is "designed to be practical and useful, rather than attractive"
- hivacruz 2y agoPHP is a great language to learn OOP, classes, interfaces, abstract classes, traits, managing dependencies and unit tests. I'm not using it anymore but I learned basically everything with it a decade ago. Thanks PHP!
- zelphirkalt 2y agoA good language to learn OOP is Pharo or Smalltalk.
- miguelxt 2y agoI've been being productive by solving real business problems with PHP since 2007. Hope to continue doing so in the future.
- padjo 2y agoWill 2024 be the year that PHP users finally feel they no longer have to tell everyone else that PHP doesn’t suck?
- zelphirkalt 2y agoI thought the blog post would introduce me to how PHP in 2024 somehow got rid of all the cruft from ages ago, but instead it merely talks about some frameworks. Probably high level frameworks are what saves PHP from dying, because they mean, that people don't have to deal with as gnarly PHP all the time, but going so far as being excited about them? Sounds more like a justification to still keep using this language, despite all the other often better language options out there. Heck, I would even prefer writing Java these days, than going back to PHP.
- johnisgood 2y agoPHP these days is pretty much fine, it is nothing like PHP 5, IMO. I started working on something a year ago and it was way better than using any frameworks. Initially I did start with a framework (Laravel), but it had its own limitations (and bloat) so I decided to do it from scratch. The code was much more manageable, understandable, etc.
- zelphirkalt 2y agoCould you share a project you did? I would like to compare to my past PHP writing. I also found, that doing my own plain PHP imports/requires worked better than what WordPress by default wants you to do for example, so I can well imagine, that something similar can happen with Laravel.
- aaviator42 2y agoI am by no means an exceptional dev, but some PHP code I've written can be found on my GitHub. None of it uses frameworks, and a bunch of it is small libraries ('components') that make up my own personal functional 'framework'/toolkit: https://github.com/aaviator42/ https://github.com/aaviator42/ Edit: Link that shows only PHP repos: https://github.com/aaviator42?tab=repositories&q=&type=&language=php&sort=stargazers https://github.com/aaviator42?tab=repositories&q=&type=&lang...
- zelphirkalt 2y ago
- la_fayette 2y agoUsing PHP with docker the default way would require several docker images to run in parallel, i.e., php-fpm, webserver, etc... I use nginx unit to have a standalone docker image with php, webserver and application, similar as you would have it for a node or spring boot application. nginx unit has no support for http 2/3 and you would require a proxy to support that, FrankenPHP seems to be an interesting alternative for my setups, will definitely check it out!
- a-l-e-c 2y agoSecond this, FrankenPHP is on my list to check out someday and linda already forgot about it. Seems like a pretty decent option. I did however end up using a Docker image to run a small local project (using Caddy instead of nginx)
- frank_bb 2y ago[dead]
- esher 2y agoPosts related to PHP usually become discussion if the language sucks or not here on HN. I am co-founder of a PHP PaaS and I can confirm that almost all clients are using frameworks or even CMS systems on top of PHP to build stuff. Why not? I am interested how PHP and frontend tooling will work out in the future. Nobody is compiling JS/CSS with PHP (as far as I see). That is usually done with Node.js. Livewire (and Inertia.js) are bridges. Sometimes PHP becomes a backend to provide an API for an SPA frontend.
- dan222 2y agoCan anyone help me as a newbie? I see many comments saying php is so simple to use, but I'm getting bogged down with Docker / Composer etc etc. There seems to be a lot to learn, am I going about it the wrong way? What's the simplest setup that I can use for production as well as dev (otherwise I'd just use laragon). Thanks.
- a-l-e-c 2y agoFor me the journey kinda started by checking which was the most common way of installing PHP on the OS I'm using. If you're on MacOS then nothing beats homebrew. The main thing is to try and use the latest stable version and then go from there. This should make life easier when it's time to update or when you start to deal with having to install/enable certain extensions. I've tried setting up Docker but finally just set everything up in Debian so I can use VSCodium without issues. In production (for a newbie) I would just go with something like a small 5-10$ VPS running Ubuntu with Plesk control panel which will help you setup and keep things updated (you'll have the option/warning of changing PHP version for each website in the control panel)
- z3n0n 2y agoOne (hacky) way to learn is to just install WordPress (apparently not fashionable these days, but I love it) and start messing around with the PHP in theme files. Turn on error reporting and just start breaking things.
- torstenvl 2y agoJust install Apache and PHP. There are plenty of LAMP stacks prebuilt out there. Amazon Lightsail has a prebuilt LAMP VPS.
- pier25 2y agoIn April 2024 PHP reached its lowest position ever in the TIOBE index. It's not even in the top 10 anymore. https://www.tiobe.com/tiobe-index/ https://www.tiobe.com/tiobe-index/
- g8oz 2y agoTiobe also has Visual Basic at number 8. I would not rely too much on their rankings.
- pier25 2y agoIt's true there are some odd things when I compare it to my own anecdotal bubble but for the most part it does reflect what I see. Python, C#, C++, and JavaScript are super popular. Ruby, Go, and Kotlin have been getting more popular. Etc. I know people who are just now getting into Laravel and I'm sure it will remain a valid framework for years. That said PHP's popularity has only been going down since it peaked around 2010. This is reflected in all metrics you can think of. https://www.tiobe.com/tiobe-index/php/ https://www.tiobe.com/tiobe-index/php/ https://trends.google.com/trends/explore?date=all&q=php&hl=en https://trends.google.com/trends/explore?date=all&q=php&hl=e... https://insights.stackoverflow.com/trends?tags=php https://insights.stackoverflow.com/trends?tags=php Ironically, PHP is a pretty awesome language now compared to the days of v4 or v5.
- emh68 2y agoLaravel is never going to be competitive with Django/Rails simply because PHP as a language is just not as easy to master as Python/Ruby. There, I said it. Lots of PHP fans write these articles about how PHP is catching up in terms of usability, but nobody is choosing PHP in 2024 (other than truly uninformed people who are just picking their project language at random). The one area where PHP is useful in 2024 is for prototyping a website quickly. As a one-person team, PHP without a framework (and without OOP) is the fastest way to build a fully-functioning complex site. I built a massively complicated site this way, in very little time. This is great because if it ever becomes popular, I can simply hire developers to rewrite it in the latest framework du jour (probably Next/Nuxt/whatever)
- 0xblinq 2y agoLOL