Slashdot Mirror


Adopting PHP Code to a UNIX/Windows Environment?

Pointy Haired Programmer queries: "I work for a Fortune 100 company that is currently using a mixture of *NIX web servers and MS web servers. This company is very slow to adopt any new technology that isn't MS. So, we are serving most of our pages either through ASP or some type of CGI. Right now, we are investigating the possible use of PHP on our network due its cross platform abilities. I really want to see this happen for us, as I am an avid supporter of both PHP and Apache. I was wondering what the Slashdot Community had to say about the situation and maybe some of the advantages and the disadvantages of PHP being deployed in such a manner." Not having used PHP before, I'm not quite sure how well the code adapts to changes in its environment. Are there any "gotcha's!" that one needs to worry about when taking PHP code from Unix to Windows and vice-versa? How well does PHP work on Microsoft Servers?

3 of 6 comments (clear)

  1. it should work by Anonymous Coward · · Score: 2

    Most PHP code will run under both Windows an UNIX (LAMP, usually) without any problems. There are a few things you should keep in mind:

    1) exec() or system()-calls
    This is obvious, isn't it?

    2) webserver-differences
    If you use Apache under Unix and IIS under Windows, you may run into trouble when you use stuff that isn't provided by PHP itself but by the webserver. Especially the names of server-vars may differ.
    Flush may not work under IIS (I'm not sure about this, might have been some other Windows-webserver). Then again, popen can only be called from an application which is run from a console under Windows, so you'll have to change your IIS configuration if you wanna use it.

    3) function availability
    Some PHP functions will not work under Windows. But this is very rare and mentioned in the manual.
    If you run into problems, the annotated online-manual at php.net is your friend.

    4) library availability
    If you want to use the full feature-set of PHP, you'll have to use some custom libraries. They may not be available under Windows.
    Another problem is thread-safety. Using non-threadsafe libraries like gdlib is not a problem with Apache 1.x unter Unix, but it is with both Apache and IIS under Windows, cause these are both multi-threaded. Only CGI will work here. Before you use a library, make sure you can use it on both platforms.

    1. Re:it should work by grammar+nazi · · Score: 3
      For further information, I suggest Web Application Development with PHP 4.0 (Ratschiller and Gerken)

      It assumes basic knowledge of PHP, and focuses on Web application developmnent. Problems with cross-platform compatibility. Large scale V. small scale projects. Planning, customizing the Zend engine. I've read about 1/2 of it and I think it's a very good book. From what I've read, this book might be exactly what you are looking for.

      --

      Keeping /. free of grammatical errors for ~5 years.
  2. two cents worth by joq · · Score: 4


    I wouldn't know the comparisons between PHP over Windows and a Nix based machine, but should you want to switch over quickly check out ASP2PHP this way you don't have to write tons of code over. I used to use PHP last year on one of my sites but moved to a hacked version of ePerl since PHP caused high loads with the scripts I had running.

    Now what was scary in my eyes was the fact that the scripts were nothing but random image and random quote scripts, and it brought the load on the server extremely high and if you think that the average 6.75 load is not high for nothing but random quotes, and images then your off your rocker since I've got it down to an average of about 2.something. Anyways I guess it depends on what it is your doing.

    mod_python is pretty neat for gui based stuff but again it can be a mem hog in its own right. Only way to get a good enough grasp is to just try it out, it certainly won't kill you lest you change all your production machines without testing. (hey I've seen it done)

    Another quick note is, stay a bit weary of reviews of ASP vs. PHP or other since no two systems will be configured to do the same tasks, and your always going to get a biased opinion whether its from an ASP developer or PHP developer. I've had my share of reading articles claiming one is better than the other for X reasons. Best case scenario TIYASOYO. (test it yourself and see on your own)