php.exe is missing. gone - php

OS: Windows 10
yesterday I install xampp because I want to learn laravel.
everything is normal. I setup laravel and all. and I got to develop some progress.
before I went to sleep, I turn off my laptop.
in the morning, I open my project and run php artisan serve. then I got
'php' is not recognized as an internal or external command,
operable program or batch file.
I try to check my environment. I found that PHP is gone from the environment. so I add PHP (again) in the environment table.
and still, got the same error
'php' is not recognized as an internal or external command,
operable program or batch file.
so I check the path C:/xampp/php. turns out, there is no php.exe
then I run where php.exe from cmd in the directory C:/. and got
C:\>where php.exe
INFO: Could not find files for the given pattern(s).
Is there any solution so I can use PHP again?

Related

How do I setup my host machine's PHP interpreter to point to the container's PHP interpreter

I would like to configure PHPStorm so that I can run Artisan commands directly from my IDE's terminal. For example php artisan key:generate. However, when I do, I receive the error 'php' is not recognized as an internal or external command.
Background:
running Windows 10 as host machine
using Docker to run my webserver (Nginx) and PHP interpreter (7.2-fpm).
I followed this tutorial.
https://www.digitalocean.com/community/tutorials/how-to-set-up-laravel-nginx-and-mysql-with-docker-compose.
One thing the tutorial didn't cover was how to set up my remote PHP CLI interpreter. For that, I followed https://www.jetbrains.com/help/phpstorm/configuring-remote-interpreters.html and can make a successful connection as it picks up the correct PHP version 7.2.21 as seen in the screenshot.
After this, I restarted my Windows 10 host machine, fired up the container, opened my IDE and tried to run php -v from the terminal but hit the error again.
I know it has something to do with my PATH environment variable being set incorrectly, or not at all but I am not sure how to point it to the container's PHP interpreter. Any help would be greatly appreciated.
EDIT
For what it is worth, I know that I can exec into the container and run PHP commands from there, but thought I might be able to do it directly from my host machine by pointing to the container's interpreter.
The terminal in PHPstorm is the same as any other terminal on your computer. It doesn't automatically connect to docker to run the php -v command. If you want to run php from PHPstorm in docker you can right click the file:
Choose run:
And select your created docker interpreter as your runtime:
If the fix button doesn't show it can be configured through:
settings > Languages & Frameworks > PHP
And then clicking on the 3 dots at the end of "CLI interpreter"

Install phpunit on windows without composer won't work

I'm trying to install phpunit manually on my windows machine. I don't use composer, so I have to install it manually with a .phar file. I'm following the instructions from the official documentation:
https://phpunit.readthedocs.io/en/latest/installation.html#windows
I've done every step, but it won't work. phpunit --version will throw me the message 'phpunit' is not recognized as an internal or external command, operable program or batch file. Can someone Help me?
I'm using Windows 7 64-bit with XAMPP 3.2.2 and PHP 7.1.1.
EDIT:
My phpunit.cmd file location is C:\xampp\php\phar\phpunit.cmd.
The file contains the code #php "%~dp0phpunit.phar" %*. I've added ;C:xampp\php\phar to my PATH variable.
In order to make Windows recognize any command, you must put the binary's path in the relevant environment variable (PATH). Before that you need to create some kind of file Windows can run natively (i.e. not a .phar – can be a command line / batch file or executable). Here are instructions:
https://phpunit.de/manual/current/en/installation.html#installation.phar.windows
Edit: If following the above instructions, it's also important to make sure that php itself is part of the PATH environment variable, so that it's possible to execute commands like php phpunit.phar.

Composer fail installation on PHP path

Im trying to install Composer.exe, and it always fail after I choose php.exe file and click next, with an error:
The PHP exe file you specified did not run correctly [exit code 1]: D:\Software(x86)\wamp64\bin\php\php7.0.10\php.exe
Program Output: 'D:\Software' is not recognized as an internal or external command, operable program or batch file.
Thing is: Path to the php.exe is valid. I have php in env variables, so if I run cmd and type in php it runs...
But if open cmd and type in path that I gave to the composer so D:\Software(x86)\wamp64\bin\php\php7.0.10\php.exe
It respond with 'D:\Software' is not recognized as an internal or external command, operable program or batch file. too.
To clarify, I restarted computer after php installation and I after added env variables.
And this is in my env path var: ...;D:\Software(x86)\wamp64\bin\php\php7.0.10\
I installed xampp on D:\ Drive and it didnt work too, then I
uninstalled it and istalled it on C:\ and it worked... Dunno what was
the problem, if someone can explain, please do. Thanks
I guess you have to escape the braces in windows. Either with a backslash or the complete folder with quotes

selenium-server-standalone first start windows 10

I'm trying to start use selenium server with my Yii2 project.
I successfully installed selenium-server-standalone on win 10 with that command:
composer global require se/selenium-server-standalone
But when I try to start selenium-server-standalone I have error message::
sh is no internal or external
command, operable program or batch file.
There is java and selenium in my PATH, also I have a selenium-server-standalone.bat file in C:\Users\***\AppData\Roaming\Composer\vendor.
Please, tell me how can I solve this problem.
You have mentioned you are trying to run selenium server on Win10 machine and error you are facing is sh is no internal or external command, operable program or batch file.
Seems you are typing sh selenium-server-standalone.bat in your command. that is for Linux.
For windows machine, simply go to your path where batch file is located (C:\Users\***\AppData\Roaming\Composer\vendor) , type selenium-server-standalone.bat and hit enter. Selenium server will start.

Laravel 5/Composer terminal error: sh.exe": composer: command not found

I get the error in the title when I try to run composer require "illuminate/html":"5.0.*" in my terminal (Git Bash) under my current project file path. Even if I type something like composer -v I get the same error.
I've even tried reinstalling composer and it installs fine but the commands still don't work.
In the PhpSTORM terminal, running the same commands gives this error: 'composer' is not recognized as an internal or external command, operable program or bath file.
I have VirtualBox, Vagrant and Laravel all installed correctly with Composer (I know it's all good because my code is great and works fine when trying it live and what not)... unless I'm missing something here (Laravel noob).
Why is this happening?
If you installed composer outside your virtual box (in your host system) and you want to use it without ssh into your vagrant box:
Make sure you add composers directory to your PATH. Then close your current terminal and reload a new one. Closing the terminal is necessary to reload the PATH.
The error sh.exe": composer: command not found indicates that the composer is not found in the current folder or the PATH.
Found out why I was getting the error: forgot to ssh.
The fix was this: vagrant ssh in the terminal.

Categories