Good Day I have been struggling lately to get the right path to execute php scripts on the command line.

My php folder is found in c:>xampp\php

which I specied as the path above by accesseing the environmet variables directory.

I was wondering whether I am doing anything wrong because if I type a comand
to create a new web application in Yii I got an error that said php.exe is not a an
a win32 applicatio.

I have tried every example it is on the internetr but somehow they do not seem to wotk

Your reply will be highly appreciated.

Regards
Your liY

Dani AI

Generated

Brief troubleshooting note tying together the replies from , and and giving concrete checks.

Basic checks (run in a Windows Command Prompt):

where php
php -v

Interpretation and fixes

  • If where php returns nothing, the PHP CLI folder is not on PATH. If it returns multiple locations, the first entry is the one the shell runs — remove or reorder any stale entries.
  • If php -v prints a PHP version and build info, the CLI works. If it errors with a message about the binary not being a valid Win32 application, the executable is either corrupted or the wrong build for the OS (32-bit vs 64-bit). In that case obtain a matching Windows build or reinstall XAMPP.
  • Confirm the PATH entry points to the php folder (the directory that contains the CLI binary), not to some other file. Environment variable changes require closing and reopening the Command Prompt (or a logoff/restart) to take effect.
  • If multiple PHP installs or tools (Cygwin, Git, Composer installers) are installed, an unexpected php binary earlier on PATH can cause this error; use where php to find and remove the offending copy.

Yii-specific note

  • When a console generator fails because the wrong PHP is invoked, run the framework command with the explicit PHP CLI found in the XAMPP php folder (absolute path) to bypass PATH ambiguity. If the explicit CLI still reports the Win32 error, replace the binary from a fresh XAMPP download.

Recommended Answers

All 3 Replies

It is normally found here:
C:\xampp\php\php.exe

See the --help output or the man page. In any case, the -t <rootdir> option on the command line will do the trick. IE, php -t xampp\php for Windows, or php -t xampp/php for Linux/Unix. I suspect that the latter will work for both, though the former (backslash) will ONLY work for Windows. Since I ONLY use php on Linux, I am just guessing, but I do have quite a bit of experience munging with php's source code (to fix some serious bugs with their http support). My current set of projects are php/javascript/css intensive, including writing (done) a cell phone web browser emulator.

Thanks a lot guys will certainly try it out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.