PHP or Python?

halfmoonforever

Expert Member
Joined
Feb 1, 2016
Messages
1,196
Reaction score
9
Hi guys,

No it's not the typical thread of which one is better and starting an argument ;)

I'm interested in building a web UI for a Linux-based application, to control it's config/restart the service.

Now you can do this with PHP, slap root on everything and call it a day, but seeing how other people have used mostly Python for some of the similar things that draw a parallel to what I want to do, it peaked my interest to exactly what tool is best for this job.

So imagine something silly like iptables. If I wanted to have something secure, with a web UI, interact with iptables config and restarting the service, which would be better? Python or PHP?

Also pretend I don't know either of the languages

Thanks!
 
I speak from a position of absolutely no experience - but wouldn't interaction with the OS be easier from Python than from PHP?
 
Given that you are probably going to have to run shell commands to do things like changing iptables (and be very careful not to lock yourself out of your website), php or python should be equivalent. There are probably other reasons to choose the one language over the other, but the running of the shell commands is probably not one of those reasons. Giving your web user super user permissions is also an interesting concern by itself, but I guess/hope this is on a play server, rather than a server containing something valuable.
 
Well, we've done something very similar to this for the bank. Basically a service that runs which controls other services with a REST/Websocket API on top of it. Through it we serve an angular site to interact with it through those APIs and also a console app because IE is stupid with websockets. We did this in Go. The benefit with this is that you get to run the application as a windows service or daemon. Using PHP you will be locked into having to run a web server and php :sick:

So between those two I'd say Python with something like Tornado for the webserver (if you follow our approach).

If I was to pretend you know neither of those languages I'd recommend you take time to learn another language like Go or Rust and use that :p
 
a windows service or daemon :sick:

FTFY :D

Thanks for the idea though. I want to approach this to be as secure as possible, as I and others pointed out, it won't be a good idea going to a production environment using a web user that can manipulate these things.

So I think I'm leaning towards Python for this as it should be fairly straightforward creating an API that could be secured and called by some web user with keys that can be revoked etc.

Unless anyone else has objections? :)
 
I would say Python, since ERPnext is quite successful regarding multi level permissions and user roles and personally I just think Python is a bit lekkerder to type than php.

PHP is my favorite language, but PHP het soms die k@k gewoonte om well php te wees.
 
FTFY :D

Thanks for the idea though. I want to approach this to be as secure as possible, as I and others pointed out, it won't be a good idea going to a production environment using a web user that can manipulate these things.

So I think I'm leaning towards Python for this as it should be fairly straightforward creating an API that could be secured and called by some web user with keys that can be revoked etc.

Unless anyone else has objections? :)

:wtf:

/checks my post
 
I'd pick Python (I'm horribly biased towards it though) simply because it's heavily used to script exactly those sorts of things and it's highly likely someone's already done what you want to do. There are probably libraries for the iptable manipulation already. Throw in some flask and good security and you're close to done.

I'll leave what I think about fudging with iptables over a web ui to another day though.
 
FTFY :D

Thanks for the idea though. I want to approach this to be as secure as possible, as I and others pointed out, it won't be a good idea going to a production environment using a web user that can manipulate these things.

So I think I'm leaning towards Python for this as it should be fairly straightforward creating an API that could be secured and called by some web user with keys that can be revoked etc.

Unless anyone else has objections? :)

Python is a bad idea, write it in go, a single binary vs having to have python installed.
 
I would say Python, since ERPnext is quite successful regarding multi level permissions and user roles and personally I just think Python is a bit lekkerder to type than php.

PHP is my favorite language, but PHP het soms die k@k gewoonte om well php te wees.

Python and PHP are both equally **** ideas.
 
@rward I put the :sick: face next to your "windows service" sentence, I don't run a windows server for PHP and Python. That's like ordering a steak at Spur and expecting it to be good. (Spur, btw, isn't a "steakranch" anymore)

I'd pick Python (I'm horribly biased towards it though) simply because it's heavily used to script exactly those sorts of things and it's highly likely someone's already done what you want to do. There are probably libraries for the iptable manipulation already. Throw in some flask and good security and you're close to done.

I'll leave what I think about fudging with iptables over a web ui to another day though.

iptables were just an example. The application and config I want to manage through a web UI is entirely different.

Python is a bad idea, write it in go, a single binary vs having to have python installed.

Python is already installed on the server by default, so nothing extra or additional overhead. I will look into "Go" anyway. Thanks
 
Top
Sign up to the MyBroadband newsletter
X