59 ms·
Go with PHP
- chasil 3y agoI was expecting something about Go.
- gabereiser 3y agoSame, didn't see anything that was remotely Go other than a generic http handler written in PHP. The other part about handling 500,000 orders a month on a $6/host isn't very impressive. You can do orders of magnitude more with just PHP. You can do that in a minute with Go.
- asddubs 3y agoturns out "go" is also a verb.
- paulryanrogers 3y agoThus is why I wish titles quoted names, at least where is there is any possibility of confusion
- smashed 3y agoNot sure how quotes would help? If referring to the go programming language, the title should say "golang with PHP" There is no other way to disambiguate one of the most commonly used English verb from the obscure (in relative terms) programming language.
- gabereiser 3y agoThose of us who program in Go are always looking at the word “go” in that lens. Our mistake.
- paulryanrogers 3y ago> Go with "PHP" And articles referring to Golang could read > Go with "Go"
- latchkey 3y agoThat's why I say "golang".
- pier25 3y agoMe too. Some kind of weird Frankenstein of Go mixed with PHP.
- 12907835202 3y agoI'm mostly interested if this is a tiny hobby project by someone who wanted a nice example to use in arguments. Or an advert by someone involved with Laravel/Laracasts. As the former it's quite effective. The latter would be funny.
- rrdharan 3y agoThey’re not wrong… PHP7+ is blazing fast, has a huge library, gradual typing support, etc. If starting a new project in the space where they all “compete”, I would choose PHP7 or PHP8 with Laravel or Symfony (or maybe even WordPress) over Rails, Django and probably over NodeJS.
- jszymborski 3y agoYou lost me at WordPress haha... Ive a lot of love for WP, but I don't really get the appeal of extending it past blogging... if you're doing anything more complicated it's pretty trivial to implement blogging functions in your site.
- tobinfekkes 3y agoThe days of WordPress being used for only blogging are long gone. I have many, many multimillion dollar clients using it as the hub for their whole company (none of which have blogs). It's crazy how it just...works. A little PHP-FPM tweaks here, a couple NGINX tweaks there, and you're off to the races. Very little maintenance, almost no downtime ever.
- zelphirkalt 3y agoYou are probably the cleanest WP + PHP developer in history, who contrary to the messed up ecosystem of WP plugins has clean coding style that puts everyone else in the WP ecosystem to shame then, or those multimillion dollar companies don't actually need that much functionality on their sites. Even the data structures in a default WP setup, making everything as post types is silly for anything not a blog and I wouldn't build anything on top of that ever again. Most of the examples (all I ever saw?) for themes are silly, because they use concattenation for HTML templating, instead of composition. Not long and a theme will become messy, unless one is very vigilant, but then code reuse inside the same theme obviously suffers. Basically the whole ecosystem is full of anti patterns that one would avoid usually, but that somehow have become the tutorial samctified way to do things in WP.
- janmo 3y ago> Your website is automatically protected against XSS, session hijacking, CSRF, SQL injection, host header attacks, and other vulnerabilities. That's quite misleading however
- nstart 3y agoJust made the same comment and deleted it seeing that you already stated it. Protecting against all of these is hard and no tech is going to automatically protect for all of this on its own. Such a weird statement to make that takes away from the message of the site entirely.
- jszymborski 3y agoThe code snippet is very Laravel, and it does a lot to stop all those attacks with that API.
- janmo 3y agoI worked for a company and we used the PHP ORM Propel. So in theory no SQL injections you would think, WRONG. We used a function like findOne() (I don't recall exactly). It looked like this: $resetTokens->findOne($GET['password-reset-token']); The issue was that findOne would accept wildcards, so one could use ?password-reset-token=% in the URL and reset the password of any random users.
- blindhippo 3y ago... why would you pass $GET through to a logical layer with access to a data store write without sanitizing it? This seems like a pretty basic thing to fix, but then I only have your snippet to go by.
- oefrha 3y agoThat’s a parametrized API that’s supposed to be safe against injection, at least to anyone who’s ever used parametrized APIs and hasn’t read the documentation of this particular library in detail. That it supports wildcard makes as much sense as log4j executing code in textual messages. If an ORM/builder casually puts =/IS and LIKE in the same method, don’t touch it.
- deleted 3y ago[deleted]
- alex_lav 3y agoUse pretty much any language. It mostly doesn’t matter.
- mproud 3y agoWe are pretty much at that point. Choose the language that works best with the tools or libraries you want to use… and if there aren’t any specific requirements, use any language you want then.
- iamluzhe 3y agoReplacing PHP/Laveral with JAVA/SpringBoot is not different at all.
- cutler 3y agoYes because PHP5+ is pseudo-Java.
- bityard 3y agoA great many good things that I still use on a daily basis are written in php. Roundcube and Nextcloud for starters. Some of the most fun I ever had writing basic CRUD apps and simple interactive websites was in PHP and Codeigniter back in the day. I'm pretty much Team Python now just because of the huge ecosystem but maybe it's time to give PHP another chance...
- scsteps 3y agoIt’s cool to see PHP getting its second heyday once again. It’s currently a perfect storm of two communities starting to notice PHP. From the JavaScript side, people are comparing React with PHP, and on the bootstrapped start up side, people are talking about just using a single index.php file for your entire product without dealing with a complex tech stack as inspired by Pieter Levels.
- awestroke 3y ago> It’s cool to see PHP getting its second heyday once again. It’s currently a perfect storm of two communities starting to notice PHP. Really? I see no evidence that this is happening
- diordiderot 3y agoThe Frontend / server less / JS ecosystem craziness and high rate of change has left a lot of devs disenchanted. High profile posts over bundlers, tailwind, and microservices set the scene. A few popular people on Twitter have been talking about Laravel which has influenced other devs. Wind is in Laravel's sails, not php's
- blueflow 3y agoPHP has never been replaced as the dominant scripting language for the web.
- evilspammer 3y agoAlmost every PHP site also uses JavaScript so I'd say not
- o1y32 3y agoawestroke asked for evidence, but your long comment provided none
- evilspammer 3y ago[dead]
- adamnemecek 3y agoIt's one of those posts again. I have no clue what compels people to write things like this.
- PrimeMcFly 3y agoI see no argument at all for using Laravel over Django or Rails. PHP was always a mess. Why would I want to come back to it now on the off chance they don't screw things up again?
- thomasfromcdnjs 3y agoExactly. array_filter and array_map, have different order of arguments. ($array, $callback) vs ($callback, $array) A small example of how inconsistent the language is from the ground up. Most people can explain their respective web servers, but I've never heard anyone even come close to what PHP/Laravel is actually "doing". Side Complaint: If you are working with Laravel Queue, it is such a hassle to reload your code changes when developing.
- ofrzeta 3y agoSo what's the programming language that's 100% consistent? For example Python isn't.
- cutler 3y agoRuby, Clojure, Go, Kotlin, Rust.
- pdimitar 3y agoI doubt any language is at 100% but from my work with them Elixir, Golang and Rust are predictable and a joy to use. I don't remember the last time their API has surprised me.
- xigoi 3y agoPerfect is the enemy of good. There are many languages much more consistent than PHP.
- lostdesign 3y agoYeah, but these things exist across languages. Laravel has collection methods that fix that and they can be used in any php project too. https://laravel.com/docs/10.x/collections#available-methods https://laravel.com/docs/10.x/collections#available-methods
- keyle 3y agoAs a fullstack developer who has worked many, many years in the javascript hellhole, I mean ecosystem, as well as the python ecosystem and .NET; coming back to PHP the last 2 years, working essentially in Laravel and the like - I couldn't approve more of this message. Seriously, PHP is the grand father that will drive you to class and you'll never be late, the car will never smell and everything will always just be fine. It's fast, it's typed (now), it's reliable. Laravel is pretty darn rock solid. I've used a LOT of frameworks. Most of them fall on their ass in either the documentation or performance scope. Laravel is beasty, reasonably well documented, handles hundreds of thousands of users without a scratch. Plays well with Redis and MariaDB or anything really. Just ignore the fugly standard library inconsistencies of (old) PHP, every language has their toilet corner... Oh and it's free. All of it. PHP, Laravel. And its hosting has always been the cheapest. You don't need a particular OS or certain cloud providers. When I consider the solutions of flask and microservices I've left behind, the many node processes running with pm2, the complexity of .NET solutions... PHP just works, and it's easy to make reliable... And if it's slow, it's because I'm doing dumb stuff, not because of dark corner edge case I happened to be tripping into. It's single threaded first, queue jobs for anything slower. That simple facts make it so much easier to reason about things, and keeps the fullstack linear, transactional and easy to reason about, 2 years into it. PHP is not the best language in the world. I prefer Swift and even Go for many reasons, but it's an easy, simple, straightforward language. It's the BMX of the languages.
- pkphilip 3y agoAbsolutely. The developer experience with PHP is so far ahead of the Javascript "ecosystem" that it is ridiculous!
- EGreg 3y agoFor a framework that is radically different but also PHP-native (since PHP 5), would you like to spend an hour playing with https://github.com/Qbix/Platform https://github.com/Qbix/Platform ? If you do, please share your experience in a comment. I’d love to hear it. I architected this framework over the last decade :)
- 3y ago
- asimjalis 3y agoThere is also Phel (Lisp-like language that compiles to PHP). https://phel-lang.org/ https://phel-lang.org/
- joering2 3y agoI think its a great reminder to code with whatever you feel comfortable. For example, my last project I did in Centos/Apache/PHP5/Code Igniter 3.1 with some WASP for protection I did for 12 years and sold few months ago. It checks out against Qualys Server test and ImmuniWeb very well. I sold it for close to $10MM with annual revenues of $1.6MM. The last question the new owner asked me was "what did you program it with?". They mostly want bunch of boring excel spreadsheets seeing where I am, how the sales are sustained, and how do I believe it can grow. On the final day, their IT guy showed up. He looked in silence through 45 minutes of my code's presentation, which is very much mix of OO and not OO, and his only words were "I don't like frameworks if that was me I would start the whole thing from scratch". So you never know what or whom you gonna get, but the bottom line is if you have sales and revenues and keep tabs on spending, they will come, and they will not care less about your fancy framework or newest code implementations. TLDR: code in whatever you feel comfortable but always consider security as top priority (not speed) because in production your code's/setup security mistakes can cost you serious legal troubles.
- sockgrant 3y agoGotta love engineers. 45 minutes of reading 12 years of someone’s work and the first thing they say is “yeah I’d rewrite it”. Every. Dang. Engineer. It’s crazy. I try to work in a codebase for 3-6 months before coming to any wild conclusions. Usually you find that there’s some warts but it does the job and there’s complexity that was solved that you hadn’t originally noticed, and it’s not worth rewriting it just needs some love in some areas. People hate reading other peoples code.
- zdragnar 3y agoA clean rewrite is almost always going to produce better code than what already exists in a project that has grown organically. The current project has had numerous iterations on requirements over the years, changes in project leadership, paradigm fads come and go, and all that time accumulating cruft and layers. Looking at it at a single moment in time, you have a fixed set of current requirements where all the discovery has already been done, plus whatever your current knowledge of future requirements is, possibly none of which may have existed when the original code was written. That doesn't mean that everyone is going to sit around on their thumbs patiently waiting for you to rewrite it to be perfect. The more lines of code there are, the more time it will take, and the more hidden features that nobody really remembers exist but are still crucial will crop up. Few situations are actually best served by a full rewrite, but almost every project would be better off if the world could stand still long enough for it to happen.
- jszymborski 3y agoI used to refresh nettuts.com obsessively in high-school and Jeffrey Way's PHP content was the highlight. Sadly the site got a refresh ages ago and is nothing like it used to be. Anyway, if you're reading this thread, thanks Jeff!
- blakblakarak 3y agoI too learnt webdev with Jeffrey back in the jQuery days of 2011 - I subscribed to laracasts at the start of the year (primarly to evaluate Laravael for work) and was delighted to see that he runs the site - he's like the Bob Ross of webdev.
- taspeotis 3y ago> It can handle more than 500,000 orders per month How many seconds in a month? 60 * 60 * 24 * 28 = 2,419,200. So basically, its performance is at least 0.2 requests a second...
- pier25 3y agoYeah... OTOH it makes a point that it solves a real problem. A business processing 500k orders a month is not trivial.
- PetahNZ 3y agoI know it's just meaningless numbers, but our php backend handles 10 orders per second peak. And obviously a order requires many more requests than just 1.
- Culonavirus 3y agoRealistically, and speaking from professional experience of over a decade, "creating an order" can be one of the most complex tasks your frontend part (as opposed to admin/cronjobs parts) of the web app is going to do. It is not a rare thing to see dozens of records in a dozen of tables being created/updated at order creation time. All of these "order creation" examples are super naive. Once you develop for a shop that operates in $10M+/year range (i.e. there was probably time and money to bloat all the user/cart/stock/warehouse/sales/dispatch/marketing operations and metadata), god forbid a shop that has lots of legacy code and data structures, you will be fine with anything around 1s at order creation. (Not that I want to defend Laravel's speed, it's not really anything to brag about, and the typical "cache everyhing everywhere all the time" aswer is not that useful.)
- hu3 3y agoI have a client that handle peaks of 7k requests/s using php-fpm + nginx + MySQL. Using their own custom framework in PHP. It all sits in a single 5 year old machine with 8 cores and 16GB RAM. Their bottleneck is actually MySQL but they have room to spare so no need for upgrades right now.
- konart 3y agoWhile 500k order does not sound as much - you have to remember an order != a request. Not to mention that as long as you have a direct sync query to a database - your code will have to wait, lol.
- mholt 3y agoI'm in the group described halfway down: was on the Internet during PHP 5, lost interest in it, and moved on [to Go]. I haven't written anything in PHP newer than version 5. Even transitioning from 4 to 5 was quite a big deal, I definitely noticed improvements. But it wasn't enough. I couldn't fit the data set in memory with PHP. But I could do it with Go. I couldn't do parallel computations in PHP in order to respond to an HTTP request quickly enough. But I could do it with Go. I couldn't reliably and easily deploy to different systems with PHP. But I could do it with Go. Eventually, I couldn't write a web server with PHP. But I could do it with Go. A lot of my early websites were written in PHP and I was able to build them quickly and routinely. I didn't really have a problem with PHP as a paradigm, or even its security and consistency posture. I'm glad they've since made an actual language spec and fixed a lot of issues with it. And I don't judge or look down on PHP programmers. I just don't think it was the right tool for my jobs.
- deleted 3y ago[deleted]
- heywhatupboys 3y agoWhen are these ever issues? In a real life scenario
- konart 3y agoIn almost any scenario? >I couldn't fit the data set in memory with PHP. But I could do it with Go. I guess this on is self-explanatory. >I couldn't do parallel computations in PHP in order to respond to an HTTP request quickly enough. But I could do it with Go. Consider the following (covers both statements above): you need to get some data from a few sources (databases etc) do some computation on each set and then do some sort of mapping to get the resulting set. You may want those computations to run in parallel and idealy you'd like to start mapping as soon as each computation function starts producing results. >I couldn't reliably and easily deploy to different systems with PHP. But I could do it with Go. I haven't been using PHP since 5 but I assume it's still much easier to just push you Go binary to a destination. Though with Docker and company deploying PHP code is not a big issue these days I assume.
- latchkey 3y ago> There is no need to compile anything. But I really like compilers, they catch a whole class of bugs, before I run things.
- oaiey 3y agoAnd static typing, and linting, and code analysis, and security checks, and .. these pipelines are long nowadays Oh and the garantiert that no one can modify it post the compile step.
- binhamstrr 3y agoWhile you don't have a proper compilation step, you can run some very good static analysis on PHP. I can't imagine not having Psalm or PHPStan in our build pipelines.
- hakube 3y agoUnit testing
- Gigachad 3y agoUnit testing is a poor mans compiler. Our medium size rails app has 40,000 unit tests and constantly we have issues where an updated library changed the name or parameters of a method without warning causing breakages.
- jjice 3y agoYikes. Is there a static analysis tool for Ruby (along the lines of MyPy or PHP Stan) that could have caught this? Also, out of curiosity, are all of those tests hand written, or is there some generation in there?
- Gigachad 3y agoAll hand written over 10 years. They catch a lot of stuff, but stuff still slips through. Generally the area of the breakage even has tests over it but didn’t manage to catch the particular issue or they had mocked out parts which ended up being the issue. I can’t see how static analysts could solve it really.
- krapp 3y ago(sits quietly in the corner wishing Hack had taken off, or at least that one of the things PHP took from it was native XHP.)
- endorphine 3y agoComing from Rails, how does Laravel compares? If you know both languages, which one would you pick? I've this hunch that there's no reason to lick Laravel over Rails, since that latter is the bees and knees for web development. Alternatively: what would you suggest someone getting into web development to learn? PHP or Ruby?
- hit8run 3y agoPersonally Rails. From a business perspective both are fine.
- solraph 3y ago> If you know both languages, which one would you pick? The one with the best density of good developers in your hiring region if the application ends up scaling. > Alternatively: what would you suggest someone getting into web development to learn? PHP or Ruby? Neither. I would tell them to get into the Javascript ecosystem - not because I think it's necessarily good, but because that's where most of the work is. I'd also reccomend picking up at least one other general purpose language to be a bit more rounded such as Golang, Java, C#, Python.
- pkphilip 3y agoI would use the PHP Yii framework - it has generation of CRUD, controllers, models etc.. and excellent customisability.
- BilalBudhani 3y agoI have worked with both Laravel and Rails. I would still pick Ruby on Rails for my projects because I feel the Ruby's ecosystem is more mature than Laravel's. Don't get me wrong –– Laravel (the framework) has some polished first party packages however, as soon as you step out to third party packages the quality drops significantly.
- jensneuse 3y agoFrom the title, I thought someone implemented PHP in go. facepalm
- ofrzeta 3y agoWe're now at Laravel 10. Take a look at the Laravel Bootcamp for a quick intro https://bootcamp.laravel.com/ https://bootcamp.laravel.com/
- kgeist 3y agoI agree with the message, but the example has: - hidden global state - arbitrary string literals Is that Laravel?
- solraph 3y agoIt's been a long time since I had to deal with Laravel, but that code snippet looks very similar to the Laravel version I had to work with ~6 years ago. I hated it (Laravel) for those reasons, along with the madness that was the DI container. Guess I'm just not "web artisan" enough.
- mekoka 3y agoAny programmers here who've used PHP to build command line tools in PHP? What is the experience like compared to, let's say Python or node.js? How good are the facilities? What are the limitations?
- muglug 3y agoI have rewritten more-or-less the same tool, 100KLOC, in Rust and PHP. I can't tell you about Python or Node.js Use PHP if - you're in a hurry and you already either know PHP, or the script is going to call other PHP code you've written - execution speed is not important (ditto for Python and Node) If neither of the above is true, give Rust a whirl.
- naiv 3y agoSymfony command is great for this https://symfony.com/doc/current/console.html https://symfony.com/doc/current/console.html But it really depends on what you need the command for. I use Symfony command for general things, Node.js for eg PDF generation, Python for ML, Rust for calculating Ranks/Scores Development time is the same for all of them. For whatever reason Node.js scripts always feel dirty to me. I can not even pinpoint why.
- porker 3y agoIt's really good. Using the Symfony Console component you get sane argument and option parsing and validation (optional/required, single or array values), output styling, interactive inputs, tables etc. If you're wanting to build a TUI I haven't seen any libraries as advanced as the Python or JS ones.
- pkphilip 3y agoVery easy to do. Check out the getOpt function for argument parsing etc.
- nunodonato 3y agohere's a nice goodie https://github.com/nunomaduro/termwind https://github.com/nunomaduro/termwind
- demurgos 3y ago
- Uptrenda 3y agoAlso: lets not forget one very important and under-rated side-effect of PHP -- it lets you write server-side code that can leverage a 'public' address. You might think 'well, doesn't everything let me do that?' Not quite. On 'free' VPS servers they usually have 'ephemeral' IPs or IPs that change. So while you get free bandwidth and compute -- it's hard to actually do anything useful with it like run a service if you don't have a public address. With PHP it's assumed it will be accessed from the web so if you run it on free shared hosting you get that accessibility built in. PHP is very good for writing services that cost literally nothing because you can run it on free hosts like 000webhost that give you everything you need to host complex services (upload, database, sub-domains, and more.) It's perfect for budget devs or maybe devs that want to make their infrastructure more resilient to ah... financial upsets...
- Gigachad 3y agoBeing able to host for free on dodgy free hosting is hardly a benefit anyone should care about.
- lostdesign 3y agoYou can throw it into lambda or vercel for that matter too. Yes you can use sketchy hosts but still can use legit ones too to host for free or very little money.
- Gigachad 3y agoYou can throw basically anything on lambda. That’s hardly a feature of php
- polyamid23 3y agoMight be useful for teenagers / people with no disposable income to start trying web related stuff from a public library.
- Gigachad 3y ago
- konart 3y agoWhy would you go with PHP+whateverframework instead of Ruby on Rails or Django? I haven't touched PHP since 5th version and I'm kind of sceptical it can offer anything RoR can't.
- pkphilip 3y agoPHP 8 is a vast improvement over PHP 5. Also, the frameworks have become much better - I especially love the Yii framework as well as the Codeigniter framework if you are looking at a Rails replacement.
- konart 3y agoI'm a Go dev these days and rather looking into TS and Rust. I was just curious to be honest. With RoR being what it is PHP frameworks has to offer something on the same level (at least) to be of any interest (as a I see it). Not to mention ecosystem\packages\gems\etc.
- pkphilip 3y agoIt is ridiculously easy to setup a full CRUD environment in frameworks such as Yii. It is as simple and selecting some options on a screen and then clicking on a button. The example below is from 7 years ago! https://www.youtube.com/watch?v=Xi0gH2izUy0 https://www.youtube.com/watch?v=Xi0gH2izUy0
- nologic01 3y agoI don't know why you are being downvoted, this is a very legitimate question. These server-side frameworks are all alive and kicking and very competitive. When some other smaller ecosystem comes up with a good idea (like elixir/phoenix) there is a rush to replicate which happens rather fast. I think in the end the competition will lead to specialization. Python will almost certainly capitalize on its data science / ML links but its not clear (to me at least) how php and ruby will differentiate themselves.
- 3y ago
- sberens 3y agoAs someone more familiar with js/react, is there an equivalently mature reactive frontend framework?
- lostdesign 3y agoLaravel has inertia, livewire or alpine to get reactive/snappy frontends if you want to have an SPA. Inertia lets you use your react while not needing to write an api. Livewire drops the js completely and does the SPA-esque frontend with php, alpine is just a smol lib to make parts of the website interactive. Generally speaking, if you use PHP to build an API, you can use react still as is.
- mongol 3y ago> It can handle more than 500,000 orders per month when hosted on a $6/month server Is this a statement from the real world? What business sells 500,000 orders in a month from a $6 server? I mean, if you sell that much, you would probably want a high-availability solution and they don't sell for 6 bucks.
- tpetry 3y agoThe message seems to be targeted at the „webscale“ folks. Something like: Look, one 6$/month server can do more than you ever need. You don‘t need {complicated stack}. Just use two 6$/month servers.
- nologic01 3y agoPlanet php has a strange and probably unique geography. It has its large continent of modern generic web frameworks but it also has these countless small but thriving islands of specialized platforms that solved specific problems. But islanders and continentals dont talk or help each other. You can obviously build from scratch a blog, a wiki, lms, forum, analytics, e-commerce, survey etc. etc. site in Laravel. The funny thing is that it is quite likely that the leading open source solution for what you want to do is already in php (wordpress, mediawiki, etc) yet you cannot benefit much from it. You definitely cannot import it, but you cant even learn easily from it unless you dig deep into a complicated codebase. Because php is so old and so adapted to web development people went on and built wonderful things with it, capturing complex domains with all their peculiarities. But that valuable knowledge base remains fragmented and locked within each one of these monoliths. Going forward there is ever more intense competition between open source language ecosystems. A lot of improvement efforts look inward (making languages faster, safer). The php community might also be able to draw unique advantage looking more "externally", taping the enormous domain knowledge of all these projects. How that could be done in practice is an open question, but it could become the USP for php, the way data science has become for Python.
- thomasfromcdnjs 3y agoI've been using Laravel for the past year at work, not a hater type but still find it meh even with all the improvements.
- jchook 3y agoPHP 8+ is filling-in a lot of the missing features -- type hints, attributes, named parameters, etc. Nowadays instead of using 'string_you_have_to_remember_and_might_mistype' or abusing associative arrays as in the given code sample, you can usually get full code completion luxury with PHP without magic comments or other workarounds. PHP 8 is still missing a few critical features such as generics and typed resource handles, and nikic left the project, but I'm still hopeful PHP 9 will deliver on those key additions.
- epiecs 3y agoLearned Python a few years back; after being a long time php dev. The named parameters and the *parameter expansion felt so nice in Python and it irked me that we didn't have that in php. Feels good that it is finally coming ^^
- simultsop 3y agoI thought this is a workaround showing off how they use Go lang and PHP together, fell for it!
- chrismsimpson 3y agoGo where exactly?
- minusf 3y agowhat this page means is: go with laravel. wordpress is also php. dont go with php.
- timwaagh 3y agoFor me the best platform is one that's easy to debug and the debugging story for php is one of the worst. Otherwise it would still be quite hard to read. But at least it's cheap to host.
- pas 3y agoxdebug is pretty okay. PHP is single threaded, the entry point well defined, var_dump/die/echo works wonders, debugable by curl and simple php -S nowadays. it has orders of magnitude less complexity than the JVM, or even the various Python server runtimes (gunicorn, uwsgi, etc) at least in my experience. can you elaborate on what you see as the debug support deficiencies of PHP?
- graeber_28927 3y agoNot sure what exactly you refer to with "debugging", but I'm personally much happier with XDebug in VSCode, spamming my breakpoints and stepping through the code inside of the editor where I edit the code. I can set breakpoints in my react app too, but it feels weird to inspect code in the browser console. And since modern frameworks get compiled for the browser, it is all even less familiar at a glance.
- simonhamp 3y agoIf you're looking for a great CMS and were bitten by WordPress back in the day, you should take a look at Statamic (https://statamic.com https://statamic.com) It's a Laravel package and it's the best CMS I've ever used (from a dev perspective). v4 just dropped the other day
- omnimus 3y agoPHP has a lot of top tier CMSes. IMHO bunch of them are even better than Statamic. Craft CMS (https://craftcms.com/ https://craftcms.com/) is a lot more mature database based CMS. Kirby (https://getkirby.com/ https://getkirby.com/) is better at flat-file and has a lot better admin interface. Twill (https://twillcms.com/ https://twillcms.com/) is better integrated in Laravel and is fully open-source. Statamic mostly feels like it's sitting besides Laravel and they call themselves Laravel based for marketing.
- simonhamp 3y agoYou're absolutely right! PHP is blessed (or maybe cursed, depeding on your perspective) for that. I believe Craft and Statamic share a root in ExpressionEngine, which I loved also. I've only used Craft a little bit, for me the biggest issue is that it is (or was when I last looked) built on Yii, which isn't my go-to framework in PHP. This is in no way a showstopper. I haven't used Kirby, but it looks like a completely stand-alone application so I'm going to miss being able to co-locate the rest of my application there with the full toolset of the framework behind, which for small sites I really appreciate about Laravel+Statamic having right out of the gate. I've also not used Twill, but it looks to be similar to Statamic (as it's also a package). Not sure how this can be more open source than Statamic tho... if you mean free as in price, I'm all for paying for great products to make sure the teams behind them can keep on churning out great work. I'm sure AREA 17 will keep supporting Twill for a long time to come, but it doesn't look to be the focus of their business. I'm also intrigued to know what you mean by "better at flat-file". UX of the admin interfaces is kinda subjective and less of a concern from a dev perspective (though it's still an important consideration if you're trying to pick the right tool for a client or another team!) > they call themselves Laravel based for marketing Same goes for Twill :) nothing wrong with hanging onto the coattails of a popular piece of tech AFAIK Statamic wasn't built on Laravel at all in the beginning. I believe Jack adopted it because it was clearly a great stack to build on top of. I think he made a great choice and I'm glad of it.
- marcus_holmes 3y ago> It can handle more than 500,000 orders per month Hilarious because other languages are capable of that per minute not per month
- cntrl 3y ago500,000 orders per minute on a $6/month server? Which language is able to achieve that?
- zer0tonin 3y agoGo
- cutler 3y agoIf you're going to pull numbers out of a hat at least provide some evidence, especially evidence based on a comparable workload.
- zer0tonin 3y agoI actually wrote a whole article about this myself: https://alicegg.tech/2023/02/06/4dollar-vps.html https://alicegg.tech/2023/02/06/4dollar-vps.html TL;DR: go can handle 1000+ RPS on a ridiculously small server
- tredre3 3y agoBut creating an order isn't just a request. PHP will also handle 1000 RPS of hello world just fine on a 4 dollars VPS. Maybe (probably) Go is still faster than PHP, but the hyperbole is being pushed a bit too far here.
- 00deadbeef 3y agoAnd what about the database?
- MarvinYork 3y ago
- azangru 3y ago> Read the following code as if it were a documentation page: If I read this as a documentation page, this makes me scared: `Order::create($validated + ['status' => 'pending']);` What does it mean to add an array to something?
- Y-bar 3y agoAs someone who likes PHP that stumped me as well, I *really enjoy working with PHP 8.1, but I could not really grok the code either.
- iLoveOncall 3y agoExactly the same as the spread operator in JavaScript or even the exact same syntax in Python, but we don't hear you complaining about those, do we?
- maleldil 3y ago> the exact same syntax in Python No, because the example is showing concatenation of associative arrays. In Python, you'd use a dict, and you can't do `validated + {'status': 'pending'}`: ``` >>> validated = {} >>> validated + {'status': 'pending'} Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for +: 'dict' and 'dict' ``` You can do `validated | {'status': 'pending'}` since 3.9, though. I think using union or the * operator (e.g. `{*validated, 'status': 'pending'}`) looks less weird, but if you're a PHP programmer, you already know what + does here. In the end, it becomes bikeshedding.
- azangru 3y agoNo complaints about the spread operator :-) But the plus in javascript produces this: [1,2,3] + [1,2,3] // '1,2,31,2,3' (never tried this in js before; so was amused by the result)
- BystanderX 3y agoIt would be shorthand for: `$validated = ['key' => 'value']; $validated['status'] = 'pending'; Order::create($validated);`
- simonhamp 3y agoAnd come check out NativePHP[1] where you can build native desktop apps using Electron or Tauri + PHP Starting with Laravel support and launching soon [1]: https://twitter.com/search?q=nativephp&src=typed_query https://twitter.com/search?q=nativephp&src=typed_query
- BulgarianIdiot 3y agoSounds like a threat TBH
- BulgarianIdiot 3y agoThe problem is this page advertises Laravel, not PHP. Ruby on Rails has many similar "demo worthy" snippets that make complex tasks seem readable and intuitive to the layman. Laravel and Ruby on Rails have something else in common: due to the focus on these "natural" interfaces, they compromise in every other way. Architecture, performance, testability and so on and so on. For those who know PHP, this code is full of singletons masquerading as static classes (which Laravel incorrectly calls "Facades") which mean no isolation and clear flow of dependencies in your code. In a nutshell, every line of code you write this way comes loaded with a pound of irreducible, unfixable tech debt. Enjoy.
- simonhamp 3y agoMaking "complex tasks seem readable and intuitive to the layman" is no bad thing - besides other engineers, future you could become a 'layman' easily. Readable, expressive code is something I've come to value highly after almost 20 years And from first-hand experience, while the specific code sample shown on this page shouldn't be treated as a practical example of how to architect a larger application, there's nothing compromised here in terms of performance or testability. All tech is tech debt at some level or at some time - what has happened to pragmatism? Laravel has actually helped me write the most performant, tested and least-refactored code I've ever written. Like any tool, used properly it will do its job well; simply grumbling and shooing it away does not stop it being a perfectly fine tool in the right hands.
- BulgarianIdiot 3y agoI guess I wasn't clear enough? I said "it makes complex tasks SEEM". My point being, they SEEM SIMPLE in a DEMO. But in real application it quickly turns into a quagmire, due to the problems I already listed. Oh look, you even say so in your own comment: "the specific code sample shown on this page shouldn't be treated as a practical example". So... you're saying the page makes it SEEM simpler than IT IS, hmm? Is this what you were asking me about "why is it bad"? You don't think parlor tricks in demo code is a bad thing? So what are you even objecting to here? I said something bad about Laravel, and you use Laravel, so you have to go on the offensive out of loyalty? I don't know why people need to identify so religiously with their tools. If we start picking apart this demo code, you'll probably admit that every line contains an anti-pattern you'd avoid in a real project of more than a modest size. So what is this demo demoing then? It's essentially misleading people about what it takes to write a good app. If we'll go by simple demos alone, PHP needs no framework at all for a good demo: <?php echo "5 + 5 is: " . (5 + 5); Boom, everyone understands this, now you can write your own Google! This is why RoR declined and it's why PHP with Laravel and WordPress as their poster boys is declining. PHP itself is no longer as terrible as it used to be, although all the good people seem to have left the internals. But the frameworks people use on it are terrible, incompetent and aggressively misleading people into bad practices for the sole purpose of marketing to newcomers.
- 1337shadow 3y agoStill a lot more to type than with Python and especially Django
- progx 3y agoPerformance is always a good argument, but, be realistic and be honest, most applications did not need ultra fast performance and most applications did not have hundreds of parallel users.
- cutler 3y ago5 seconds per request isn't anything to shout about in 2023.
- tiku 3y agoLaravel gets over 2000 requests per second in PHP 8.1 https://kinsta.com/blog/php-benchmarks/ https://kinsta.com/blog/php-benchmarks/
- cutler 3y agoUnless you specify the hardware and compare with the OP your claims are meaningless.
- vntok 3y agoWhere does this 5s/request come from? Are you misreading the word "requests" instead of the word "orders" that is in the article?
- SergeAx 3y agoI see couple singletons calls in those examples. Is it considered a good practice in PHP now, or was it made to simplify the demoed code?
- simonhamp 3y agoMaybe you mean 'static' calls? Depends on the context but in most cases these are a convenience, syntactic sugar. Take SendOrderToVendor::dispatch($order)->onQueue('orders'), for example. This could also be written as: $job = new SendOrderToVendor($order); $job->dispatchOn('orders'); (Exact function calls may not be correct, I'm on my phone) Functionally identical - same code path. The main gain is ergonomics, but it's entirely your choice how you prefer to write this code.
- motogpjimbo 3y agoThe issue isn't the exact syntax that's used to access the service object. It's the fact that any random chunk of code anywhere in the codebase can reach out to any other random piece of code. Syntactic sugar or not, that's considered to be an antipattern in pretty much any community outside of Laravel's.
- motogpjimbo 3y agoLaravel calls them "Facades". And no, they're not considered good practice outside the Laravel community.
- ChrisMarshallNY 3y agoI’ve been writing PHP for over 20 years. I use it for my hosted (backend) programs. Works a treat. It’s robust, fast as hell, easy to make secure, runs on the cheapest, crappiest hosting, and has an enormous support infrastructure. That said, I’ve never particularly liked the language, and have never become an advanced adept at it. I use it to manage the less-glamorous part of my work. I’m mostly a native Apple developer (Swift).
- zerr 3y agoIsn't it too much "string oriented"?
- anonymous344 3y agoof course php is best, but how do u do in app(web app/browser) notification with 6$/month apache & php? for example if there are 2000 users who need to push a message to when a queue job finishes in php backend?
- 00deadbeef 3y agoLaravel lets you run tasks in the background. You just queue up those notifications and then some other task you wrote will come along and start sending them. Apache isn't involved.
- anonymous344 3y agoThanks. My queue is done and working, but how can i make php to have websocket for thousands of devices ? I know it's javascript in the frontend and i could do some kind of timeout loop to check job status, but that's not good..
- _8j50 3y agoPHP malware on windows is a thing now too lol
- deleted 3y ago[deleted]
- sourcecodeplz 3y agoThe fact that you can build a whole app inside just one index.php file is highly underrated and I understand how newbies finding this out are getting excited. I remember when Rails first launched and I wanted to try it but it was so complicated to get started.
- RadixDLT 3y agosorry to break it to you, but symfony is much more superior and flexible than laravel.
- sublinear 3y ago[flagged]
- jasongill 3y agoI would say that the thing that gives web devs a bad name is an attitude like yours.
- sublinear 3y agoI hope you're nobody's boss. Talent doesn't come from mild mannered yes men and doesn't look like plastering over decrepit slop.
- chwilson 3y ago> The fundamental flaw is still with the community preferring server-side rendering of pages Server side rendering is a flaw?
- zapt02 3y agoI hope you will mature one day and that you will see that whatever bad experience you had with PHP (probably many years ago if not decades) is not universal.
- e12e 3y agoI think I'll stick with rails if I want cute DSLs and lots of magic ("… broadcast an event to update the frontend in real time …"). But sure, it's great that php has come a long way since php3. That aside: > It can handle more than 500,000 orders per month when hosted on a $6/month server. Surely it can do more than 700 orders per hour, 1 order every 5 seconds? > The only additional fees are for a CDN (if you want your assets to be served faster) and a domain name Uh, so no managed database, but you recommend paying for a CDN before slapping Varnish in front of your static assets? I get that php might be eminently usable at this point - but this seems like an odd pitch.
- languagehacker 3y agoI am an erstwhile PHP apologist. Having come back to PHP after a long time away (not really by choice), I can confirm that the language has improved significantly since PHP5. PSR was a huge success in a lot of ways. However there are still a few things that prevent it from being my language of choice. First off, there is a surprising number of core behaviors you'd expect from a modern web application that there isn't a clear go-to for in the PHP world. Does anyone know of a well maintained library for publishing and consuming AMQP messages asynchronously? PHP is still limited by living inside of the context of the request. This has an effect on certain types of application-layer caching, and makes for a poor model for backend scripting. You also still need to interact with multiple layers of dependency management -- from os packages to pear packages to composer libraries. Configuration can be messy, and many projects still aren't containerized. Finally, while the language has evolved, many of the projects that use it have not. The longer lived the PHP project, the more likely you are to encounter the exact paradigms that make it so hard to work with. Other languages have benefitted from a much greater percentage of their lifespan being supported by ecosystems that encouraged keeping your dependencies and the parts of your code that exercise them up to date. That being said, it's great to see that there is a path for starting new projects with a modern framework. But I would have said the same thing about Zend or Symfony, and those seem to have fallen off for reasons I don't know.
- mrunkel 3y agoAsync Messaging: https://symfony.com/doc/current/messenger.html#transports-async-queued-messages https://symfony.com/doc/current/messenger.html#transports-as... Some of your complaints are a little weird. * The OS package/pear package thing is highly dependent on what language features you want to add to the base language. If you want, you can install all those features with pear. It's just easier to install with OS packages. * Composer used to add libraries to your code base * The fact that "many projects still aren't containerized" has nothing to do with PHP. I doubt there are many languages where that statement isn't true. * No idea why you think Symfony has fallen off. Laravel has large chunks of Symfony code inside it and the project is going strong with regular releases.
- phpisatrash 3y agoThe "Good Luck" at end speaks for itself.
- CR007 3y agoI've been using PHP for about 19 years and what I can tell is that both the language and its community have evolved the right way. Writing modern PHP is a joy, IDE support is great and we have tools for everything. Modern PHP is about community standards, not about any particular framework and exposing Laravel as the best way to get started with PHP is questionable. I wouldn't recommend it to anyone wanting to learn (real) PHP. The article praises PHP but it is sad that doesn't link to any other resource or project which ditches the value of PHP community. Laravel is great for RAD which is attractive for small projects. The kind of stuff "business with 500K orders runs on a $6 VPS" thing. For clients wanting a robust software system you can use a better tool.
- 0xblinq 3y agoThe only bad part of the PHP community is the people that have never done anything else other than WordPress. The shittiest more careless horrible and bad practices riddled codebases I’ve seen in my life come from WordPress developers. It has nothing to do with the language though, it’s just that part of the ecosystem which I think is what drives all the negativity and looking down towards PHP.
- mrunkel 3y agoYeah, I think phptherightway.com does a much better job introducing people to modern PHP.
- pier25 3y agoSo Laravel is not robust? Honestly asking. Haven't written PHP in over 20 years.
- rawfan 3y agoLaravel only seems to be for small stuff like - the backends of Apples Webapps - spiegel.de, the biggest German news site - the New York Times website - backend services at Disney - About You (large online retailer) Seriously, though, I myself work for an enterprise that runs big parts of the European energy grid and we use Laravel for all sorts of stuff. At a previous job Laravel powered a whole ISP. Notice when people say Laravel is good for small stuff and early prototypes, they never explain why.
- barneygale 3y ago[flagged]
- fHr 3y agoI too was a junior that was plagued by wordpress and php custom plugins, never again will I touch this language if I can.
- Tade0 3y agoThe other day I finished a side gig I was doing - a Wordpress site recreated using the Wayback Machine - the site went down a while ago and the admin stopped answering phone calls, not to mention emails. It was a largely pleasant experience, taking me back to my early years as a "web developer". I had to modify some PHP files because the theme used didn't offer slots for widgets in places I wanted it to. That being said uncached the site takes over 20 seconds to render. CPU load wasn't high so I can't help but wonder what was it doing all this time.
- jwie 3y agoI’d had a site in a similar state, and I did figure out what it was doing. Client had launched a product that was a bit more successful than typical. Nobody could access the site though. I dig around a little, come to find a neat little snippet of template looking for a featured user for some markup. The genius who set this up iterated through each record trying to find the featured item. One query at a time, testing each record in the application for the flag. Php is fine, some very inexperienced “developers” use it though so you find a lot of gems like that in the space.
- VWWHFSfQ 3y agoThat PHP code right there at the very top of the page that is supposed to be representative of how great it is has multiple TOCTOU authorization and validation bugs. In fact, nearly every piece of code on that entire page is riddled with transactional bugs
- keen_poincare 3y agoIf you may, could you point out what are the TOCTOU bugs you have mentioned?
- VWWHFSfQ 3y agoEverything between checking if the user can "place-order", and then validating the inputs, and then finally creating the order.
- keen_poincare 3y agoI don't think the request object can be modified by the end user or that it is modified by the server at that point. If my belief is correct, does this code still contain TOCTOU bugs?
- VWWHFSfQ 3y agoIt's the underlying state of the database that will change between these different checks. Not the end-user modifying the request object, which is in PHP memory
- keen_poincare 3y agoThanks for explaining it.
- njovin 3y agoDo you mind elaborating? I can see how the user's ability to 'place-order' might be rejected between the access check and the order creation but that would be an extraordinary edge-case that does not need to be accounted for in 99% of applications. If you're developing an application that needs to account for such an edge case you could easily do so with an insert w/ join method on the Order model. The author isn't trying to show that the code is bulletproof for every scenario.
- lastangryman 3y agoThere's 2 things to separate here: 1. PHP the language and developer experience (frameworks, tools, community, docs, etc) 2. PHP performance at scale In my experience, PHP is much improved for 1. and fine to work with. Laravel and composer are great. For 2. I would never use PHP on anything above a few hundred requests a second. It's slow on its own, but more importantly it's blocking IO model will grind things to a halt at any level of concurrency when talking out to database, caches, or other services. You are also vulnerable to issues like saturating your database with connections due the programming model in php-fpm. I know async php exists but my impression is the mainstream frameworks dont support it (I could be wrong?) so why not just switch language at that point. I speak from experience of scaling a Laravel php app up 5k RPS+ and needing a LOT of EC2 instances to do it. Using Go was a revelation and delivered a 10x improvement in terms of resources required to serve the same number of requests. So yes, if your rps < 500, why not, PHP is fine. For anything above that, it's a not a great choice. (And defining your scale in terms of orders per month is a bit silly)
- pdimitar 3y agoWeird that you get down-voted but I lose more and more respect for HN these days so I can only say I am not surprised that a common-sense post was given the gray treatment. I have the same experience as you, I've participated in migrating from PHP to JS, to Elixir, and to Golang. The transition to JS was mostly a performance disaster (not much performance was gained) but at least more devs could help so it was still a big win organization-wise, whereas the transitions to Elixir and Golang were a screaming success on every front: we immediately gained anywhere from 7x to 25x more req/s and the DB load was stable and the request timeout errors dropped by 97.9% on the first day (and were completely eliminated a week later), not to mention the cost of our hosting also dropped by at least 70%. I am past my phase of "hating" languages but honestly, saying "PHP is not the right tool for jobs X and Y" is a "hate" in the eyes of many anyway. And yeah it's not good enough for big scale. I mean, if you make $1M a month then you likely don't care much if you pay $50K in hosting, sure, but why do you have to spend 5% of your revenue on hosting? There are a lot of modern technologies with which you'd be hard-pressed to justify having more than 2 application servers and 1 DB server (with read-only backups and replicas if sh_t hits the fan).
- o1y32 3y ago"500,000 orders per month" That's like, what, 12 orders per minute? Is this meant to be impressive or something? I bet any language run on a modern laptop can handle that.
- randshift 3y agoI thought the same thing. PHP is a fine tool but that is not a value add statement. The code can "handle" anything, it's the underlying OS and related systems that limit the load.
- paledot 3y agoOr smartphone.
- ceejayoz 3y ago"when hosted on a $6/month server" Dropping half a sentence will often make it sound goofy, yes. The point being made is "you don't need a massive K8s infrastructure to handle hundreds of thousands of orders a month". Most people don't; https://www.joelonsoftware.com/2001/04/21/dont-let-architecture-astronauts-scare-you/ https://www.joelonsoftware.com/2001/04/21/dont-let-architect... is an oldie but a goodie on the subject.
- smt88 3y ago> "you don't need a massive K8s infrastructure to handle hundreds of thousands of orders a month" This is true of many languages that are slower and faster than PHP. It's not useful as evidence of PHP being a better choice for anyone.
- ceejayoz 3y agoIt's not an argument of "this is the absolute best possible choice". It's an argument that raw language performance in this sort of context isn't going to be the problem for 99.9% of people developing code. If you have 500k orders a month, you can afford more than $6/month in hosting. I sometimes see folks post on StackOverflow trying to micro-optimize things like string concatenation or single versus double quotes that make perhaps a second of CPU difference in a million executions. The point is directed at those folks; the ones who are thinking "language X is faster, and for that reason alone I should use that instead".
- xcombelle 3y agoI just don't get why people in php use lazy comparison when you know that "0e4"=="0e5" in php. and yes, Laravel use lazy comparison (hundreds of times). And yes at least three bugs where caused by this use. see: https://github.com/laravel/ideas/issues/698 https://github.com/laravel/ideas/issues/698 for why I'm a bit grumpy with php ecosystem
- JodieBenitez 3y agoWhy do most PHP related posts on HN read like repentance ? If you want to promote the language -to the point of buying a domain and making a webpage-, please show interesting stuff, not something that is equally trivial to solve in gazillions of web frameworks written in gazillions of languages.
- rafark 3y agoI don’t get that feeling. And I like that people are doing their best to try to improve the reputation of the language. The reality is that modern php is very decent, but a lot of people that have never used it or have used a very old version mock or look down upon it for no apparent reason. It’s important to try to improve the reputation so that it gets new developers interested in it in order for the language to keep being relevant. If you want a concrete reason why I think php is great and has many things that are very useful compared to its competition: Extensive native support for classes and types. Php does class-based OO better than its competition (JavaScript, python). Designing a traditional object oriented system using classes and interfaces is better in PHP than in JavaScript and python, if we limit ourselves to the native features of the language. For example, you cannot define a native interface or an abstract class in python or JavaScript. JavaScript classes, since they’re just syntactic sugar, have a lot of unexpected behavior. In python you have to accept the this/self object in every method definition. Here are a couple of links about php classes, interfaces and types for anyone interested: https://www.php.net/manual/en/language.oop5.variance.php https://www.php.net/manual/en/language.oop5.variance.php https://www.php.net/manual/en/language.oop5.interfaces.php https://www.php.net/manual/en/language.oop5.interfaces.php
- JodieBenitez 3y agoYou just prove my point... you start your post with something that reads like "it's decent now, please look at PHP again". But: - you make bold claims about PHP OO - you make downright false points about other languages - you nitpick things that are non-issues in other languages All in all, nothing in your post really seals the deal about PHP. It's not about mocking or looking down on PHP for no apparent reason. I'm pretty sure most of us on HN have used it already and most of us have followed its development. I sure did. And every time a new version comes out, I welcome the improvements although it's just mostly catching up with the competition. So what compelling reason do I have to use it again in 2023 for greenfield projects ? None. It used to be "the web specialist", but now all platforms have great web frameworks along their distinctive features.
- ynniv 3y agoPHP has 99 problems, but shipping code ain't one
- krylon 3y agoThe last time I used PHP was in 2004 or 2005, PHP was at version 4.something, and I did not like it. That kind of formed my opinion on the language, even though I know it's come a long way since. OTOH, I have no reason currently to take another look. But it's nice to be reminded, I guess, PHP isn't the dumpster fire it was 18 years ago.
- jwithington 3y agoI hosted a phpBB forum as a kid in the early 2000s. 15 years later I joined a marketplace startup that was doing 10,000 transactions a day. Built as a PHP monolith. I was sooooo confused at first. “PHP??? That strange language I used to host a forum is powering this app??” Turns out the founding engineer was self-taught and PHP had the most tutorials or something lol
- pdimitar 3y agoDeveloper advocacy is such a weird thing, do it right and people will line up for you to mentor them and pay you for it, do it wrong and you will people scratching their heads asking "so you can do with this thing what you could do with Perl + CGI 15-20 years ago and still not get more performance out of it?". Sadly this article is the latter. I'm working on both sides of the fence -- dynamic strongly typed language (Elixir) and static strongly typed languages (Golang, Rust) -- so I am already sold on the advantages of dynamic languages. That page is doing a poor job selling PHP to me though, f.ex. it's not clear when you do `$request->user->orders`, does that automatically go to the DB? Does it first fetch the user and then all their orders, or does it do it in one go? Is the whole thing prone to N+1 queries like Rails is (was? no clue about it nowadays)? Posting cute little coding snippets is skipping 99% of the story. The code must remain small and simple and understandable and easy to dissect / troubleshoot, long-term, and allow for adding metrics / telemetry, analytics and such. So OK, we get it, you're so hyped about PHP that you made a website about it. Alright. Now do a cookbook. Next show us a 5-year old project and tell us how long does it take to add a feature or fix a bug exactly. Tell us of the issue that took you the longest to troubleshoot -- and why did it take so long. Before that this is basically a surface-level marketing page that says almost nothing and is not even accentuating the strong sides of your loved technology because what I am seeing here I can clearly remember 5 other languages I've done it successfully with: JS, Golang, Elixir, Rust and Ruby.
- crazydoggers 3y ago> Is the whole thing prone to N+1 queries like Rails is (was? no clue about it nowadays)? Rails has had the ‘include’ method which solves n+1 since version 3.0 around 2010. Before that it also had preload which worked similar.
- bpbp-mango 3y agoEven if you write modern strongly typed PHP and make sure to handle all your exceptions you will still encounter null (and other) errors at runtime. The language is ok these days and far faster than Python & Ruby etc but still I would not choose a new project to use it.
- 0xblinq 3y agoCan anyone with experience in both compare modern PHP and Laravel vs modern Ruby and Rails? Which one would you choose and why, assuming you have the same experience in both? I’m asking because I keep hearing Ruby on Rails is the best for starting a SaaS, etc but from my little experience on it, it seems to me Laravel is way better. Is it just a “language” thing? That most people prefer Ruby to PHP?
- jrsj 3y agoPHP is pretty nice these days but salaries for PHP roles are terrible. I can get paid 50% more being half as productive writing Go (for no reason bc 90% of people using it don't actually need any of it's features or performance)
- openthc 3y agoIn 2001 I started a PHP project and it was cool, lots of people were going that way. In 2008 folk we telling me it's a terrible security risk. In 2014 they told me it's the WORST choice. In 2023 it's cool again?
- marcrosoft 3y agoNo thanks. Those code examples are full of indirection and the bottom example reminds me of the object nested spaghetti mess of large PHP frameworks. Just because code reads well doesn’t mean you can understand easily what it actually does.
- qprofyeh 3y agoThere's joke amongst PHP companies that modern PHP has finally, completely become Java.
- JustSomeNobody 3y agoOkay, but you didn't mention Go at all in the article. Jeffrey Way is a really good teacher, btw.
- MattyRad 3y agoI actually think this article undersells PHP, as it doesn't mention the incredible additions that PHP 8 introduces, nor does it mention excellent static analysis tools like PHPStan. I recently rewrote a PHP web app in Rust (https://soapstone.mradford.com/riir/ https://soapstone.mradford.com/riir/) and although it was interesting, I think it would have been better staying a PHP app. As nice as the Rust compiler was, I felt PHPStan would have automatically caught a similar number of bugs, all the while feeling less combative.
- danielinoa 3y agoThere is a syntax error in the example shown by that article. If you must use any time to find it then you should not go with PHP.
- jrm4 3y agoNice. I needed this today. I teach "Advanced" Web Programming and my classes start next week. I've been generally ignorant of most of the kazillion fancy Javascript frameworks and have more or less kept PHP as the base of the course. This is what more-or-less has felt right most of the time.
- vonseel 3y agoFor "Advanced" Web Programming, I don't really feel like you're hitting the mark by sticking with PHP. Sure, it works, and will probably get the job done for most web projects any of your students will ever work on, but if you want to get people excited while making them employable, it's important to teach new tools and frameworks. Unless the "Advanced" part is more about the techniques and patterns and less about the language, I think you're doing them a disservice by not branching out. And, of course, you can teach patterns and techniques in any modern language. I'd expect to see some discussion of async job processing and front-end web frameworks in any advanced web programming course, high-school or college level. Honestly, just teaching the usual react stack with a typical node backend would probably be ideal since JS is approachable, react is still "cool", and you still only need to use one language.
- pphysch 3y agoThe problem with PHP is not that you can't write great maintainable codebases in it -- you certainly can. The problem is how easy it makes it to write obscenely unmaintainable anti-architected code bases in it. The average PHP production code base is deeply offensive. I'm knee deep in one right now. You can still have awful code bases in Rails or Django or Go, but the opinionated nature of those ecosystems makes the average much better than PHP. If "PHP" were synonymous with "Laravel", that would be different. But it's not.
- Xeoncross 3y agoI built and maintained open source frameworks in both. I left PHP for Go. 1. with http://sqlc.dev http://sqlc.dev I don't have to write ORM or model code anymore. Define all your SQL in an easy to audit file and all your models and interfaces are generated for you. 2. with http://goa.design http://goa.design I can have well-documented OpenAPI API's that any team can generate a client for in any language. It also generates the HTTP JSON and gRPC clients/servers for me so I can focus on my logic. 3. with https://github.com/99designs/gqlgen https://github.com/99designs/gqlgen I can define GraphQL revolvers that play well with sqlc (any RDBMS) or I can use a key-value store. 4. speaking of key-value stores, Go allows them to be embedded! Even SQLite now has the https://litestream.io/ https://litestream.io/ project to make it super simple to use a durable, always backed-up SQLite database even in a serverless context. Go is faster, uses less memory, uses types, has built-in formatting, package management, benchmarking and testing. Go supports multiple cores in the same process, and has really-well designed stdlib without all the bugs I used to face trying to use the PHP stdlib. After writing millions of lines of PHP for years, there is nothing I miss anymore. Laravel still wants me to write models, controllers and views by hand and make all the client changes as by-hand code refactors. Go lets me focus on the actual logic instead of waste my time in PHP writing all the implementation details like controller requests handlers, db fetching logic, and input validation.
- devmor 3y agoIt sounds like you haven't touched PHP in a very long time. Your comment reads like a 2015 forum complaint - which, to your credit, certainly would have been all valid points 8 years ago. The language has evolved since. The ecosystem has evolved since. Most of the things you're complaining about are solved paradigms that no one does manually anymore unless they're trying to drastically improve on ecosystem tooling. Even your complaints about Laravel are solved by open source tooling in its own ecosystem. Nothing about your preferences are really unique to go - most, if not all of these tools exist in many popular languages. The one solid point you have is that go lets you do many of these things by default without adding anything. To which I say: Duh. Go doesn't have a massive ecosystem of backwards compatible projects to continue supporting. It was barely used outside of niche cases until 2-3 years ago. In 10-15 years time, I'm sure people will say the same things comparing Go to a newer language.
- devmor 3y agoThere's a lot of reasons to both use or not use PHP, but of all the ecosystems I've developed in, PHP has the most lovely dev tooling. Every popular piece of dev tooling in the PHP ecosystem feels like it was made to solve a problem, do so as simply as possible and let you know all the information as cleanly as possible. There's contemporaries to most of those tools in every other major language, and all of them have problems or annoyances that I feel simply don't exist in PHP's tools.
- cryptos 3y ago$request->user()->orders->create($request->validated()); This looks so wrong from an architectural point of view! A request has a user (which in the context of HTTP should be more or less only an authenticated principal), which has orders, which are created from the same request, where the journey started. There is no separation of technical and business concerns. See: https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-a...
- BafS 3y agoIt's terrible indeed but Laravel pushes for this kind of "fluent" apis
- hankchinaski 3y agoLaravel is probably the top reason why I moved away from PHP to Go. I find it frustrating to have to learn custom DSL and custom syntax to do basic stuff. Which then of course if you learn is going to be useful until the next major version of the framework, at which point you will have to re-learn everything over again. I like how I can just know the Go standard library go into dozens of different projects and still being able to contribute because there are no custom frameworks and DSLs.
- kmod 3y agoI always dislike the "requests per month" metric because it seems like a transparent attempt to impress with a larger absolute number: 500k requests/month is 5sec per request, which feels pretty underwhelming
- vntok 3y agoWe are talking about 500k orders/month, not requests/month. Placing an order from the Web will almost always involve multiple requests.
- codedokode 3y agoI don't like that in the code validation rules are applied to a "request" (and written in a controller) but not to a model. This means that if you want to create a model somewhere else, you cannot reuse validation code.
- tinus_hn 3y agoA major downside of phps model is that there is no continuously running service, so you can’t run timers or background cleanups.
- throwaway423 3y agoYou are touting the language's ecosystem or tooling but the language itself is horrid. PHP is carried by Laravel. Another language carried by tooling is Go. The language itself doesn't even have sum types, lmao.
- lzomedia 3y agoI mean yeah as a php dev for 12 years since i've started picking up python , i find myself nowdays coding stuff in python :)
- deafpolygon 3y agoI have a soft spot for PHP. I love code I can write, then just refresh the page.