tekx – cross platform php

Talk is by Elizabeth Marie Smith (@auroraeosrose).

PHP is officially supported on:

  • Unix
  • Windows
  • Linux
  • Embedded Systems
  • Risc
  • NetWare
  • I5 (or whatever it’s called this week)

PHP is starting to drop support for old systems. Like 5.3 won’t run on Windows 2000. So try to keep up to date. “If you’re running PHP 4, GTFO”

If you write your code right and you get a crazy manager that decides to move, you don’t have to deal with the headaches. For the most part, PHP takes care of the hard stuff. You just need to know the edge cases and know the key differences.

Unix has been for a long time. It was developed in 1969. Different distributions which fall under Proprietary, Open Source and BSD. There is a standard file system setup. Most are case sensitive. They are CLI based. Looking at the shared libraries. ELF and Mach-O. Linux is just a kernel.

Windows is case insensitive, NTFS is case sensitive. Half of the windows programs don’t know how to do this.  It is a GUI based system with drive letter abstraction for the files system. Using FAT really messes up PHP so if you’re using it, GTFO. Look in the superglobal for the environment data, never assume any environment data like installed on C:/.

DLL HELL

SxS is the fix and only 2 people on earth know how to use it (documentation…Sigh). Most important thing to know about DLLs: What is my search path. Your directories are listed in the PATH environment variable. You have to make sure to not set it system-wide. Bad juju. Going to have to link to the slides to the one titled “The Horrible Error”. Until windows has apt-get, you have to know your system.

Installation and Configuration

On Unix/Linux, you use a distribution or compile your own. Distributions will screw things up. They backport security fixes and add extensions that change behavior (like Suhosin). They alter header files. Stripping binaries of symbols, will turn experimental flags on, turn off default extensions (–disable-all), take forever to update versions, and using system libraries instead of bundled versions. Basically, you should build your own and don’t ever rely on the system distribution. Though distributions are great simple installs for newcomers and some offer support.

How do you decide? If it’s a production box, you NEED to compile it yourself. You need to know what you’re putting there. Distribution is good for the dev machine, unless you have a crazy person who will want to deploy it from the development box.

Windows is the only system for which PHP currently provides binaries. Use PHP’s binaries or compile your own if you’re brave. It’s not as scary as it sounds though. The dependencies are the trickiest part.

Environmental Differences

Mostly $_SERVER contents. Use isset() and never assume a variable is there. Also clean the data, don’t assume because it’s from the system that it is safe.

DON’T HARDCODE ANYTHING.

Main server difference between IIS and Apache is in the SAPI not the server.

Be careful with streams and sockets. Another gotcha is process spawning (com can help in some cases with wscript.shell stuff). Be sure about using platform specific stuff (pcntl, etc). If you run into somethign that doesn’t work the same way on multiple platforms, you should file a bug. If you want your bug to go to the front of the class, be sure to write a good test case.

Reblog this post [with Zemanta]

3 comments on “tekx – cross platform phpAdd yours →

Leave a Reply