What's up with my PHP installation?

kartvelo

Well-Known Member
Lifetime Member
SoSH Member
Aug 12, 2003
7,717
At home
I'm trying to get Composer to install, and I keep getting an error message:

PHP: syntax error, unexpected "!" in C:\php\php.exe on line 1

So I thought there was a problem with Composer or its installer..... but then I opened a Command Prompt and entered

php -v

...and it returned this:
PHP: syntax error, unexpected "!" in C:\php\php.exe on line 1
PHP 7.4.8 (cli) (built Jul 9 2020 11:30:33) (NTS Visuaal C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright Zend Technologies

So php is there, and the command line even returns the correct version info,... but first it also gives me the same error message I get when trying to install Composer.

I've uninstalled and re-installed php a few times now, restarted IIS, uninstalled the failed installation of Composer, started from scratch - no difference at all.

My web browser opens php pages on my localhost server without a hitch.

I need to get Composer running before I can install yet another app, so I'm dead in the water until I figure this out.

Thanks!
 

InstaFace

MDLzera
Silver Supporter
SoSH Member
Sep 27, 2016
13,011
Pittsburgh, PA
1) Try a different, earlier version of PHP, see if it's different. Windows installs of development environments can often be wonky and may not be as thoroughly regression-tested.

2) If your browser opens pages on localhost, it means whatever CGI handler is set in IIS for .php files is working correctly, no? So is it just the CLI that has this problem, or is other execution of PHP scripts having an issue? That clue may help you narrow it down.

3) StackOverflow is your friend.
 

kartvelo

Well-Known Member
Lifetime Member
SoSH Member
Aug 12, 2003
7,717
At home
I spent many hours googling places like stackoverflow to no avail, which is why I was nagging you guys! :)

The problem is resolved, but I can't tell you why. It would appear that I finally found the right combination and sequence of uninstalls, re-installs, .ini file edits, system environment variables, IIS restarts, and system reboots. Now, just as long as no one ever touches a thing,.......
 

HriniakPosterChild

Member
SoSH Member
Jul 6, 2006
13,163
500 feet above Lake Sammammish
Time to unplug the computer and put it in a closet.

Seriously, if you can’t reliably repeat the install, you are only incurring technical debt by treating the problem as solved. Give it enough time and it will bite you in the ass.
 

kartvelo

Well-Known Member
Lifetime Member
SoSH Member
Aug 12, 2003
7,717
At home
Under normal circumstances I'd agree completely, alas. As the saying goes, it's expensive to be poor.
 

InstaFace

MDLzera
Silver Supporter
SoSH Member
Sep 27, 2016
13,011
Pittsburgh, PA
On AWS, you can spin up a t2.micro instance on EC2, have it run Amazon Linux 2, install PHP with a single command, run a web server with not many more commands, and be running scripts and such pretty damn quickly, in an environment that it's more tuned for (*nix, rather than Windows). For free. And if you ever need more juice, you can just switch the instance type to a more robust one, and start paying for it (and shut it down when you're not using it, to stop the meter from running).