Using php under DOS in Windows

I’ve been coding php for many years, and it’s become my favorite scripting language.  I don’t know why, but things just seem easier to code, make sense, and are easy for me to read later.  It’s most likely because the code looks like C, but still incorporates all the good things only a scripting language can do, such as named array items and on-the-fly character substitution.

So I needed to code a fairly simple script today on Windows 8.  My choices were a BAT script, which I know very little about, or Regina REXX which I had previously installed.  Regina is nice and I’m very familiar with REXX from my mainframe experience.  But Regina has left out the EXECIO instructions and that always seems to cause me problems.  I’d much rather use php fopen/fclose for this.  Plus, in my humble opinion, there is no language better documented for the user than php.

Turns out php is available of course for IIS, Microsoft’s web server.  I don’t need that because I’m not foolish enough to run IIS.  But does it come with a DOS command line interface, similar to the php command in the Linux version?  Yes, it does, and here’s what I did to install:

Download and Installation

On that page, let’s try downloading the top link, which is “VC11 x86 Non Thread Safe (2015-Sep-04 02:29:45)”

I’m not exactly sure what the difference is between thread-safe and non-thread-safe, but since the top one is non-thread-safe (and I don’t plan on programming things with multiple tasks), let’s try the NTS version for now – and x86 which is the 32bit code, since that page currently indicates the 64bit code is “experimental”.

We get a 20M zip which includes all sorts of directories, dlls, and php.exe. I bet that’s the install – you probably just copy all those files to a new spot. The unzip results in about 50M of new files.

Included file install.txt is a mile long. Instead of reading anything, let’s just try to run php.exe.  Uh oh, we get this error:

The program can’t start because MSVCR110.dll is missing from your computer. Try reinstalling the program to fix this problem. 

Hmm… I don’t see any mention of that file in the install doc and it doesn’t seem to be included. So let’s download MS Visual Studio C++ Redistributable 2012 and see what happens. Couldn’t hurt right? My poor laptop gets the brunt of these kinds of things.

Well, that was easy and now php works under DOS!
Easy as cake. A piece of pie. (I just watched 2010 on Netflix)

So let’s just copy the entire unzipped directory to c:\Program Files\php5 and add that to the command prompt path. To add the path, Start->Control Panel->System->Advanced System Settings->Environment Variables find PATH and EDIT, add the following to the long list: ;c:\Program Files (x86)\php5\

Done!  I owe somebody a donation I think. But who?

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>