views:

139

answers:

6

Is it wrong to use PHP as a server side language? For functions such as mail notifications / fraud checks (look for data, flag, then email type approach) / db cleanup / upload folder cleanup / cronjob type functions etc;

I've ran into some projects lately where I've been successful with this approach, but I'm not sure if its the wrong way to go? Maybe I should do the web app in PHP and the server side in something else? Any reason to NOT do it? I don't want to get into a bad habit if I can help it.

Have any of you ran into this scenario?

I should add that my reasoning for doing so is that I've been mainly a PHP dev for years, I know it very well as opposed to other languages which might be more geared towards server side

A: 

I suppose on one side if it gets the job done it doesn't really matter what you use. On the other hand there are probably different hammers to knock in that server-side nail.

John Nolan
+2  A: 

Why would it be wrong? If you know the language then use it. It can be especially useful if you reuse the code of your webpage in your PHP CLI scripts. I write all my maintenance scripts in PHP and haven't had any problems.

ps: PHP web app is a server side thing :)

Jan Hančič
+5  A: 

It's quite ordinary to use PHP for administrative tasks (cron jobs, etc.) which have no UI at all. No problem.

I wouldn't be surprised if it would be more disruptive to require proficiency in two languages.

le dorfier
I will claim that a good developer can pick up the rudiments of a language enough to do simple maintenance. Our shop runs Perl, Java, Ruby, PHP, Javascript, Bash scripts (+ Grep, Awk, Sed) and Python. While no one is a 'masters' for each, everyone knows enough to **get stuff done**, and we're always learning.
BryanH
A: 

If it was wrong then they wouldn't have a way to run php from within a script.

PHP is just a scripting language, but it is one that can be used within a webapp, but, basically it is a scripting language.

If it does what you need well, then continue to use it.

If you find that you have to do a lot of contortions due to limitations you find with php then go to a different language, one that suits your needs, but, until the, have fun.

James Black
+1  A: 

Use the language that best supports what you want to do.

  • If you're going to be doing a bunch of string processing, perl is one of the better choices.

  • If you need speed, then a (possibly pseudo-) compiled language might fit your needs, such as C, C++, Java, etc.

  • If you want to do something simple, then batch scripting (+ grep/awk/sed/whatever) might be what you're looking for.

PHP definitely has its uses, but if that's all you know, then you're locking your future up in a box and putting yourself at a disadvantage. Pick up a copy of "The Pragmatic Programmer: Journeyman to Master" -- one of the key gems is to 'learn at least one new language a year'.

Then you'll know the answer your own question above.

BryanH
Don't get me wrong, I know a few other languages, except when it comes to server side processes, PHP seems like my top contender (my languages: Flex3 / ColdFusion / ASP Classic / ASP.NET)
Jakub
Sounds like a perfect opportunity to learn a new language! :)
BryanH
A: 

In short, no unless you have a language that you 1) know better and/or 2) is better suited for the job. While some may not like it, PHP is after all, a server side language.

Justin Johnson