Portability of PHP from windows to Linux

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • seth

    #1

    Portability of PHP from windows to Linux

    Hello,

    I am new to the open source environment. We have to develop a web
    application using Apache/PHP/MySQL on Windows (A component that we want
    to use is available only on Windows for now). Later when the component
    is available on Linux, we would like to move the code.

    The web application is a simple one - collects data, does some simple
    validations and stores in the database.

    I would like to know how portable the code will be. Do we need to
    rewrite a lot of code when we move from Windows to Linux? What are the
    issues I need to be aware of?

    Thanks for your help,
    seth

  • ZeldorBlat

    #2
    Re: Portability of PHP from windows to Linux

    Probably not too bad. The main thing would be adjusting any hard-coded
    paths to files -- both in the code and in php.ini (since the filepaths
    in Linux use / to separate directories). You will probably need to
    check permissions on directories and files that the application
    requires.

    The other place you might run into trouble is connecting to any
    databases -- only because modules and extensions are loaded differently
    under Linux than they would be on Windows. That's more of a PHP setup
    issue than a code problem.

    There are probably also differences in how you might interact with the
    operating system -- especially the file system. Opening and writing to
    files, etc. might have slight different requirements or limitations
    under a different OS.

    I'd say that it shouldn't be too difficult, but be prepared to spend a
    little time adjusting your PHP configuration and make some minor code
    changes. Above all, test it first!

    Comment

    • Kenneth Downs

      #3
      Re: Portability of PHP from windows to Linux

      seth wrote:
      [color=blue]
      > Hello,
      >
      > I am new to the open source environment. We have to develop a web
      > application using Apache/PHP/MySQL on Windows (A component that we want
      > to use is available only on Windows for now). Later when the component
      > is available on Linux, we would like to move the code.
      >
      > The web application is a simple one - collects data, does some simple
      > validations and stores in the database.
      >
      > I would like to know how portable the code will be. Do we need to
      > rewrite a lot of code when we move from Windows to Linux? What are the
      > issues I need to be aware of?
      >
      > Thanks for your help,
      > seth[/color]

      If it is simple what is the component that will only work on Windows?

      It is usually the case that all of the really nifty components are more
      readily available on Linux, because PHP is really just an interface into
      the many libraries available on that platform.

      --
      Kenneth Downs
      Secure Data Software, Inc.
      (Ken)nneth@(Sec )ure(Dat)a(.com )

      Comment

      • Nicholas Sherlock

        #4
        Re: Portability of PHP from windows to Linux

        seth wrote:[color=blue]
        > I would like to know how portable the code will be. Do we need to
        > rewrite a lot of code when we move from Windows to Linux? What are the
        > issues I need to be aware of?[/color]

        The code I wrote that works fine on my local EasyPHP testing server
        (Windows) failed on a commercial server (Linux) because table/field
        names in the MySQL database were apparently case sensitive on the server
        (Worked fine here). Watch out :). All lowercase names is a good standard.

        Cheers,
        Nicholas Sherlock

        Comment

        • NC

          #5
          Re: Portability of PHP from windows to Linux

          seth wrote:[color=blue]
          >
          > I am new to the open source environment. We have to develop a web
          > application using Apache/PHP/MySQL on Windows (A component that we want
          > to use is available only on Windows for now). Later when the component
          > is available on Linux, we would like to move the code.
          >
          > The web application is a simple one - collects data, does some simple
          > validations and stores in the database.
          >
          > I would like to know how portable the code will be. Do we need to
          > rewrite a lot of code when we move from Windows to Linux? What are the
          > issues I need to be aware of?[/color]

          Generally, PHP code is portable with zero rewrites, unless OS-specific
          extensions are used. For example, shared memory and semaphores are not

          available on Windows, while COM is available only on Windows. So an
          application relying on shared memory or semaphores will not work under
          Windows, while an application using COM will work only on Windows.

          Check the documentation for extensions you are using for any
          OS-specific
          notes.

          Cheers,
          NC

          Comment

          • Peter Fox

            #6
            Re: Portability of PHP from windows to Linux

            Following on from seth's message. . .[color=blue]
            >I would like to know how portable the code will be. Do we need to
            >rewrite a lot of code when we move from Windows to Linux? What are the
            >issues I need to be aware of?[/color]
            Not a big issue, in fact I would say just the same as going from one
            version of something to another: There might be odd niggles which cause
            frustration but nothing to cause you to do any serious rewrites. You'll
            just find that something that worked fails possibly with an error and is
            fixed by trivial tweak to paths, filenames and permissions. This might
            be due to different versions of PHP, mySQL, Apache and sillynesses with
            config files.

            Bottom line is assume it will work as-is but be prepared for some
            tweaks.

            --
            PETER FOX Not the same since the statuette business went bust
            peterfox@eminen t.demon.co.uk.n ot.this.bit.no. html
            2 Tees Close, Witham, Essex.
            Gravity beer in Essex <http://www.eminent.dem on.co.uk>

            Comment

            • Al Kolff

              #7
              Re: Portability of PHP from windows to Linux


              "Nicholas Sherlock" <n_sherlock@hot mail.com> wrote in message
              news:df38he$hfs $1@lust.ihug.co .nz...[color=blue]
              > seth wrote:[color=green]
              > > I would like to know how portable the code will be. Do we need to
              > > rewrite a lot of code when we move from Windows to Linux? What are the
              > > issues I need to be aware of?[/color]
              >
              > The code I wrote that works fine on my local EasyPHP testing server
              > (Windows) failed on a commercial server (Linux) because table/field
              > names in the MySQL database were apparently case sensitive on the server
              > (Worked fine here). Watch out :). All lowercase names is a good standard.
              >
              > Cheers,
              > Nicholas Sherlock[/color]

              I have had the same experience. The bigger problem was different versions of
              PHP and MySql on the Windows and Linux servers. Usually the Linux servers
              seem to be running newer versions.

              Al Kolff


              Comment

              • Andy Hassall

                #8
                Re: Portability of PHP from windows to Linux

                On 31 Aug 2005 00:43:46 -0700, "NC" <nc@iname.com > wrote:
                [color=blue]
                >For example, shared memory and semaphores are not
                >available on Windows[/color]

                Actually shared memory is available through: http://uk2.php.net/shmop
                The example script runs fine here on Windows 2000.

                But presumably you were referring to the System V IPC stuff.

                --
                Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
                http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

                Comment

                • seth

                  #9
                  Re: Portability of PHP from windows to Linux

                  People,

                  Thanks for all your replies. The information you have provided is
                  really helpful. I really appreciate you all for taking time to respond.

                  It started me thinking.
                  Can PHP call APIs in a 'custom windows dll' as effectively as ASP?
                  Looks like there could be some issues here, based on some of the posts
                  I saw.

                  Thanks,
                  seth

                  Comment

                  Working...