Home PHP PHP in Windows
PHP in Windows PDF Print E-mail
Written by Nate Lyman   
Thursday, 14 January 2010 21:15

I know a lot of people in the PHP community are LAMP stack evangelists.  I am one of them.  However, there are times when you must work outside of the LAMP environment.

At work, I am in an enterprise Windows environment.  Instead of LAMP, we use what we like to call WIMP.  Windows, IIS, Microsoft SQL Server, and PHP.  There are a bunch of burdens of being in the WIMP environment.

The first obvious burden is admitting that you are a Windows/PHP develop at user groups and conferences.  Other developers look down on Windows/PHP developers for various reasons I understand (Think script kiddie on his mom's desktop). But, for the most part, Windows/PHP developers are just as good as their LAMP counterparts.

I will now outline a few things for new Windows PHP developers to keep in mind when they are getting started.

Windows


Windows is not Linux, and it never will be. Understood?  Good.

A lot of issues that pop up when developing PHP on Windows are related to Windows permissions.  What user is IIS running as? Does that user have permission to the file you are trying to open? etc...

To get Linux like utilities, find, grep, etc... Download a copy of Cygwin.  It is a command shell wrapper that has most mature Linux command line utilities integrated. Even SSH.


IIS


Not going to lie.  IIS is the weak point in the WIMP stack. 

For small installations the PHP-CGI implementation of PHP works well.  For bigger installations I would recommend using the PHP ASAPI dll file to do all your PHP work. 

If you have a site that is outward facing with a lot of connections coming in, I'd consider using Fast-CGI.  It is extremely flexible (multiple PHP.ini files per server, configurable parameters, etc...), it persists PHP threads for improved performance, and it can handle a lot of threads.  The persistent threads remove the PHP setup/teardown time on each request.  Per request it isn't a huge savings, but if you have 1 million requests, you get the idea.

If you have any control over your environment, go with Windows 2008.  IIS 7.0 ships with it, and it is a lot easier to configure than prior versions (IIS 6 on Windows Server 2003).


Microsoft SQL


Biggest beef with MSSQL?  No LIMIT implementation.  Only UI folks will really care about that.

MSSQL does have some great advantages, especially if you are doing a lot of Batch/Backend development.  Bulk Insert makes it extremely easy to ingest a text file into a database table.  BCP alternatively makes it extremely east to export a Query into a text file.  A lot of the work I do is in the backend, so Bulk Insert/BCP are definite life savers.

Microsoft just release a new MSSQL driver for PHP, and it works well.  I recommend it.


PHP


exec() works, but not for everything.  You shouldn't use it in frontend code at all, and use it in backend code when absolutely necessary.

PECL extensions are under-supported for windows.  A lot of them are really out-dated, or have no Windows support at all.  You can download the source, but compiling in Windows can be a bit tricky compared to doing it in Linux.

File functions don't always work, unlink(), copy(), rename(), etc...  This has to do with permissions most of the time, so you have to run your PHP script as a User that has privileges.

Last Updated on Friday, 22 January 2010 05:11
 

Add comment


Security code
Refresh