I have done quite many projects with clients in PHP, but now I have moved away from PHP to Node.
I would like to know what do you guys have to say...
For further actions, you may consider blocking this person and/or reporting abuse
PHP lets you create bugs and security issues super easily. The only consistent thing about PHP is its inconsistency. It is so bad that Facebook created Hack to make it usable. The only powerful thing about PHP is that it's Turing-complete, buy hey so is brainfuck.
That summarily covers my opinion of PHP.
You can create bugs and security issues super easily with nodejs too.
In modern backend environments php is not used naked anyway, most of the time your framework will be based on secure and field tested components (mostly coming from Symfony). Laravel is based on symfony for example, you can also very easily create your own custom and secure framework using symfony components.
I would say that PHP is still quite valid as a backend OOP programming language. Especially with PHP 7.
NodeJS can replace php for the best in many areas where php used to be chosen by default, for a lack of better alternative, but that doesn't make php irrelevant. Not everything needs to be a micro service, and many projects use both php and NodeJS.
PHP is uniquely bad in that the people behind it continuously make bad choices in designing the language.
T_PAAMAYIM_NEKUDOTAYIMhas existed since PHP 3 and is still visible as part of parsing errors today. It should be renamedT_DOUBLE_COLONbut somehow still hasn't been, and the manual entry makes it seem like it's a cute and quirky feature of the language. Oh look! You have to know a very specific subset of Hebrew to work your way around the code!php.net/manual/en/language.oop5.pa...
PHP doesn't abort execution and show a 500 on error. No. Instead it just sends the half-finished paged with an error at the top that is guarenteed to break the page.
PHP wasn't designed with you running a server process, and any framework that tries to use PHP this way undermines itself completely by having to spend 98% of its development time working against the fact that they're trying to run a modern 3D game on top of SNES-like architecture. PHP was made to be the OG serverless language, running per-requests instead of as a daemon process. But even that very core feature of PHP was butchered.
No attempt has been made to standardize the signatures of standard library functions. Sometimes snake_case, sometimes pascalCase, sometimes nocase, sometimes the verb is first, sometimes the noun is - and for array functions, sometimes the array goes in first, and sometimes last!
PHP is the only language with a configuration file assigned to it. Not a list of language features to turn on/off, no. Configuration that will change the way the language works. Which means you can't take the code from one server to the next and expect things to work. You also have to take into account the configuration of PHP itself.
While JavaScript has its share of "wat"s itself, comparison in PHP, and more generally type coersion in PHP is a PITA, and that's a huge euphemism. Oh, and while JavaScript's
==is weird but understandable, PHP's==, oh boy...These aren't usage errors, where the developer wrongly assumes something about the code itself and unexpected behavior emerges. These are weirdness coming from the language itself, which makes it extra hard to wrap your head around how to use the language itself, and as a result makes you more prone to errors.
Finally, someone will say "oh but language X or Y also has these quirky features". Oh it's okay then, some other language is weird in this aspect, therefore it's okay to put it in PHP. Therefore PHP really is Frankenstein's Monster of programming languages.
Oh yes. That and more.
On a sidenote I thought that T_PAAMAYIM_NEKUDOTAYIM was fixed in recent versions but it seems that it was actually not. 🤦
I'm surprised there is no other languages in the error messages though
Yes, i really felt that NodeJS can replace PHP, i have had failovers in PHP where my website was attacked and stuff, but as far as NodeJS is going its going pretty smooth but because i came from PHP, i really find that PHP is a good language to start with in making good programming concepts.
Your comment reminds me these words from Rasmus, I quote "PHP is perfectly consistent, just not in the way you expect".
I think it's interesting that we haven't mentioned that PHP (typically) runs in the context of a larger web server, and that NodeJS does not. In my experience Node applications typically provide a web server (like Express) and are then proxied through a webserver that serves a larger site, like Nginx or Apache.
Perhaps this is why we see many Node applications outside of a web server (command line tools, console utilities, etc.) and rarely see PHP being used for much aside from websites.
I'm not sure that NodeJS is all that much faster than PHP. While I suspect that NodeJS code might be faster at certain tasks, I suspect that PHP will be more performant in general.
I have this problem that remain unsolved until now. There is mod-php in apache to manage php, but I don't know how to handle node serve like mod-php in apache does. do you have any suggestions?
For now I create increment port from 3000 to 300X and then proxied to port 80 to apache, (in my server there's multiple node server running proxied to apache) and i think it's not effective
I think for node, i would consider PM2.
Its a process manager for Node
PM2 Process Manager
This will auto detect whatever number of CPUs you have and will manage it accordance to it. You can customize but gotto refer the docs.
I think from PHP to node was a hard shift, but not i see not that harder, its like best of both worlds, i suppose.
thank you for explanation, do you have idea for handling port?
I think if you start it with a your.json file, you could kinda hack around like this.
your_file.json
Let me know, what you find.
oh i see, that was great idea. Thank you!
Gosh. I would pick php at any time of day. Node.js isn't made for large projects...
Who think php is trash and insecure are just stupid and never learned how to work with php or any other server side lang.
Good luck with js back end.lol.
I cant read this comment section...
Nodejs isn't made for large projects? Who are you kidding?
You just sound like my college who's afraid to learn something new because it goes beyond your area of expertise.
There's a reason mostly every company moves from PHP to Nodejs or .NET.
TS + Node is far superior than PHP.
github.com/nestjs/nest
Btw I have basics with node.js socket.io and Iam quite good at net. I wrote realtime pos system on it, but I would not use node where I dont need(I mean execute exit process software).
Thank you very much for highlighting this
A week ago I started learning Node and I feel myself in my plate). First step was ExpressJs. It's cool tool, but Restify is better for me. In my opinion, Node is better for me (Cause I've moved to backend from frontend and it was not painful)
PHP and Node attempt to solve the same problem from different points of view. PHP considers the server-first perspective while node considers the client-first perspective (generally speaking). Node has the advantage of having a larger common (COMMON) user base and the disadvantage of being a bigger target for abuse. PHP libs have been around a long time and are less likely to have new hacks against them but have a history of exploits because of managing applications.
Before I get flamed! ....
I agree that anything you want to do in php is also possible via node. Javascript is simply more popular in hireing circles etc. PHP is considered a downtrend technology because of it's limitations relative to (server side) python, etc. IMHO PHP perceived limitations don't make it better or worse than javascript -just different.
I guess the point I'm trying to make is that if I inherited a PHP project I wouldn't bother to force it to be node based unless necessary. Otherwise I'd probably start a new project with node (or python depending on the situation).
Agreed, this is a debate that needs a common answer because as 2 or more devs get together that first think comping out is PHP vs Node.
hello, thank you for make it clear
as you can see here
it only run one service, my company is SaaS so probably in one vps there will be tens of different project and to run different project with manual port handling will take more time
I think the comparism isn't fair enough. PHP is a programming language while Node isn't. Node is a runtime environment to run Javascript on the backend. So any comparism between the two will be off context.
Each language has its strengths and weaknesses that is why I hate to compare languages.
If the language isn't relevant anymore then you won't find it around.
Oh well, I assumed that frameworks would make sure that
req.param('name')is a valid unicode string while$_GET['name']can be any string of bytes but maybe I'm expecting too much?In any case, you can write stupid code in all languages. But to be specific to the
$_GETissue, it's so easy to break encapsulation using it (because it's global). Same thing with$_REQUEST, what is the point of this except getting X-whatever-scripting attacks from all sides?PHP is just next-level compared to anything else in terms of possible misuses.
Node is great for prototyping any type of application, PHP is great for templates.
You might have wrongly tagged this with #docker though its good advice to run your projects inside containers as there have been some trojans in NPM packages which won't be very effective when running in a container. if you use node please make sure you know who made your dependencies and transient dependencies, you are trusting them! Also always set your dependencies to fixed versions and use package-lock.json!
I know I'm playing with fire here so please keep in mind that starting and endless discussion is not my intention.
I prefer PHP over Javascript. They are both programming languages and choosing one over the other is a mater of personal preference. People keep mentioning Node.js but that's a runtime for javascript with mod_php being the same equivalent for php interpreter in Apache. They are made for different purposes; Node.js apps are standalone apps which are better suited for persistent long lasting connections for example, while php is meant for exec-and-exit situations like single page renderings, etc. I have even written shell scripts in php just because syntax is more to my liking than bash.
You could also do a long running apps, persistent connections and numerous other insane endeavours with php, but maybe with a lot more effort than doing the same thing in Node.
Once again, I am not a fan of Javascript but have used it on both client (React) and server (Next). Beginners will for sure find asynchronous Node programming much harder than php. I don't understand how php syntax if more complicated than javascript 🤔
PHP is constantly being updated and has come a long way and although It's been a while since I last used it, I'm sure the security issues are much less frequent nowadays.
Maybe I'm just biased since php was my first web language, but it deserves some respect and it certainly doesn't deserve all the flame coming from javascript-only developers.
P.S.
Anyone remember Tomcat App Server? 😉
Lolx rules are rules we didnt make em so we gotta follow em... I think what you might be embarking is creation if a new language above a language...
The evolution of assembly to java and beyond now
Yes, although it's mostly a front-end issue. On the back-end if you try to access DB data in a non-async way you'll quickly realize that the data is simply not there. I've been handed large amounts of amateur JS and there was MANY issue but not really that one.
The kind of issues that PHP enables are more like "let's execute this unfiltered user input" which is way more dramatic than a randomly-bugged front-end component.
I still find setting up a PHP server not as easy and straightforward as a Node server. Is that true for most of you?
Depends if you build it up from a bare nude OS or not. Anyway I never set up a NodeJS capable web server, only did it for PHP and it was as easy as chaining commands. Got my website up and running, set up some cron for my Laravel Queue jobs, just a breeze.
Also have the same experience with a Xampp local config (and thinking on switching to Docker containers for my next project).
I think it really depends on what environment you are setting up. There are many scripts now written to single install all what you need, it does come with extra but you get past the headache.
Cool. Thanks for the clarification.
with help of Docker now this should be easy
Any Go developers having a laugh here?? xD
I'm a 2 year old Node.js dev & a 5 year old Php dev. I think what makes a good programming language is it's ability to attract programmers & consequently make them stay.
That's Node.js for me.
Note: learning node.js from a php background is challenging @ first because it has somewhat completely new concepts but once you get the hang of it you'll realize there's a module for almost anything you want.
I find PHP's syntax to be very confusing when compared to other modern, programming languages.
How is its confusing I just fail to understand if know java and c/c++ php is just the same
Using arrows instead of periods was enough to confuse me. lol
NodeJS. VS Poorly Heat Pattern!
Null or defines equal VS PHP
I agree with you... but i tired press $ on keyboard for variable... unless you...
and you got lot of discussion when you try make post about 'node vs php'
Thanks for the response Jorge, i dorecommended pm2 because if the process fails of some error it just restarts it. Hope you'd agree
I agree but what can you say... Its just how it goes and how it has gone with perception