0

I'm using Windows. I installed phpspec package with composer, I added the folder phpspec/bin/ to my system's path variable. But when I try to run phpspec command I get the following error:

'phpspec' is not recognized as an internal or external command,
operable program or batch file.

Even when I run the command directly from the bin directory where the phpspec.php is stored, I get the same error.

Amaynut
  • 4,091
  • 6
  • 39
  • 44
  • 1
    `phpspec.bat`? A file without extension cannot be run in windows. So it must either have `.exe` or `.bat` extension. – zerkms Jan 10 '15 at 04:12

2 Answers2

1

unlike *nix, where you can put a shebang on top of the file to make it executable, on windows you have to run a php file with C:\php\php filename.php (or php filename.php if php is in your path), so windows won't recognize a php as executable, even though its in your path.

If you do want to be able to invoke it plainly as phpspec, rather than php /path/to/phpspec/bin/phpspec.php, then inside of the bin folder, make a phpspec.bat file with 1 line in it:

phpspec.bat

php phpspec.php %*

and now you should be able to run phpspec as a command.

chiliNUT
  • 18,989
  • 14
  • 66
  • 106
  • It doesn't work. I created the file phpspec.bat with the content you suggested, but I still get errors when I try to run phpspec. When I run phpspec outside the bin folder I get the same error "'phpspec' is not recognized as an internal or external command,". When I run it inside the bin folder where phpspec.bat is located, I get the following error: Could not open input file: phpspec.php – Amaynut Jan 10 '15 at 16:44
0

In the root folder does

php bin\phpspec.php

is it work? If not what does phpspec.php look like i.e. is it plain php?

Josua Marcel C
  • 3,122
  • 6
  • 45
  • 87
Miles
  • 1