When I try to use Webception over wamp server on my windows 7,8 the below error appears for each tests
'php' is not recognized as an internal or external command,operable program or batch file
I have already installed php and the path is correct. Does it need more setup? How I can fix this issue ASAP?
This is because windows does not know where to find the php.exe file as it is not in a folder that is on your PATH environment variable.
However, when using WAMPServer it is a VERY BAD IDEA to add the path containing the php.exe to your PATH in the traditional way, because of course in WAMPServer it is possible to have many version of PHP available within one instance of WAMPServer.
The best solution in a WAMPServer environment is to create yourself a little command file that you can run from within a command windows that will add the php path you want to use for this specific project.
So create yourself a .cmd file and place THAT file in a folder that is already on your windows PATH environement variable.
So for example :-
File = phppath.cmd
PATH=%PATH%;c:\wamp\bin\php\php5.5.12
ECHO --------------------------------------------
php -v
ECHO --------------------------------------------
Of course you can make this as clever as you like and accept parameter specifying the php version you want to run, but untill you actually have more than one PHP version installed this is good enough.
I was also having a problem with webception on wamp failing to find php despite it being available on user and system path.
I found that wamp on windows by default does not provide environment variables to PHP.
I fixed this by editing php.ini (in apache/apache/bin/php.ini)
and ensuring that the following is set
variables_order = "EGPCS"
As at the current webception version 0.1.0 there is a bug to do with path generation that fails tests because the test file cannot be found. There is a solution for this at https://github.com/syntithenai/Webception/
Related
Afternoon everyone,
I'm a student studying Computer Science and I'm trying to recreate the environment my friend is using to host their PHP based web app. They're on a Mac using heroku local (Procfile calling heroku-php-apache2) to set up their environment. I'm on a Windows 10 PC, and from what research I'm done, heroku local is not supported in any way. So I enabled WSL installed Ubuntu 18.04 and Apache2 and, as far as I can tell, downloaded and installed all of the other components necessary to make it run (composer, modrewrite, modenv, etc). phpinfo(), heroku's sample project, and any simple php pages I make display properly. My friend's app on the other hand is still giving me trouble.
They're using a .env to declare project specific environment variables that are further defined in a config.php. The app is deployed and works in Heroku and on their machine, but when I try to load the app locally on my machine I get an exception thrown saying the environment variables aren't being loaded. If I add "local: php -S localhost:80" to the Procfile and run heroku local on Ubuntu, it sees the .env file and says its loaded, only to kick back the same errors my apache2 instance is throwing.
What could be causing this? I've edited php.ini to include an "E", enabled modrewrite and modenv, made sure my .env file was encoded in UTF-8 - I've searched far and wide for a reason this might be happening but I keep coming to a dead end. Is there something about the "heroku local" command and instance that I'm missing? I'm still new to php, web servers, and programming in general, so any relevant information regarding why my .env file isn't working or any possible ways I can get heroku local to work on Ubuntu using WSL would be massively appreciated.
I'm using WSL and am similarly having problems with my .env not working properly.
Although I'm still looking for a more elegant fix, the hack I'm relying on now is:
Copy the contents of your .env to a temporary text file.
In that text file, do a regex find-and-replace searching for "\n" and replacing with "\nexport " (with a trailing space).
Move the final line's "export " to the first line.
Copy the contents of this temporary text file.
Paste into your terminal to run these commands.
Now you should be able to run your app.
Straightforward Method
You can do this very simply by adding the environment variable to your .bashrc file, assuming that your Windows Environment variables are set correctly and WSL is installed, I'm going to use Java as an example, but any environment variable will work.
Use text editor in WSL or type code .bashrc from WSL home to initialize the WSL VSCode editor. Add the environment variable to the file:
# Shared environment variables
export JAVA_HOME=/mnt/d/Java/jdk11.0.4_10
Just ensure that you change the directory to point to your directory. In my case, it's in D:\Java\jdk11.0.4_10 which in WSL is /mnt/d/Java/jdk11.0.4_10
Also, since you're using Windows binaries, you must specify the file type when running from a WSL bash shell:
Example
Windows:
javac MyClass.java
java MyClass
WSL:
javac.exe MyClass.java
java.exe MyClass
Note that the .exe file extension is being used, since we're calling the Windows binary. If it was a native Linux distribution of the JDK you could simply use java command.
This holds true for any Windows binary that is being run through WSL.
I'm trying to get my Laravel project to work. But when I use composer update it says the following:
This package requires php >=5.6.4 but your PHP version (5.5.12) does not satisfy that requirement.
I'm using WAMP which runs php version 7.0.4 this is also confirmed in the browser if I echo the php version. But when I use php -v in the console it shows that I'm using PHP version 5.5.12 (cli).
I've searched a bit around on google and I found out that it uses my windows PHP version instead of my webserver's version. But I couldn't find out how to update my PHP version on Windows.
My PATH contents are as shown in the following image
You can uninstall composer, and while re-installing it will ask you to point at your PHP directory which is going to be C:\wamp64\bin\php (usually) at that point you can choose which PHP version you would want to use. good luck.
This means you have yet another installation of PHP in your system. Check your Programs in Control Panel and remove such installation.
However, you can modify your PATH environment variable as well. Procedure
Just remove the path that points to any PHP installation directory.
Else, otherwise, if you are unsure about changing the PATH variable (which can lead to serious problems if not set well), you can just delete the directory that the PATH variable points to.... (I mean the PHP directory)
The totally better solution is to add the path of your PHP7 bin directory at the beginning of the PATH variable. You should also make available composer in this PHP7 bin directory.
Such as, replace the C:\php in your path with C:\wamp\bin\php7 or whatever the location of the PHP7 path is..
To update PHP on Windows 10.
You must put the folder of the new PHP version in the same folder as the old.
You rename the old folder or you delete it, prefer rename the old folder,
now you write in a terminal console
php - v
PHP automatically check for a new version
if you had installed before xampp/wampp and composer globally you might had added php to you environment path to call it where ever you want, and now you want that composer use the new xampp with php the you recently installed, so go to system>advance tab> environment variable> maybe in PATH then search if you have something like C:\xampp\php and edit to your new php location.
I had multiple versions off xampp for testing and composer globaly instaled for php 7.2
I have an application hosted in a Windows machine that has two versions of PHP installed.
It's out of my control because there is another app of another vendor that somehow needs to use an older PHP version ; my app uses apache and the other vendor's app, IIS. The two PHP versions are installed in different folders, mine on 'c:\app\php' and the other vendor in 'c:\php'.
The problem is , when i go INSIDE the folder my PHP version is located (c:\app\php') and run PHP.EXE in command line, i get this error :
The procedure entry point php_checkuid could not be located in the dynamic link library C:\PHP\ext\somedll.dll
Why is this happening ? I'm calling PHP.EXE in the folder 'c:\app\php', not in 'c:\php'. How to fix that ?
The solution for me was set the PHPRC environment variable to the folder of the correct PHP instance (c:\app\php). Before it was set to the wrong one (c:\php).
To do this search Windows for 'Edir environment variables for your account', look for 'PHPRC' and set it to the correct folder of the PHP instance.
Put in the Windows Environmental Variable 'Path' the path of the php version you want to use.
Copy the complete content of phpForApache.ini to the php.ini file in that folder.
After that open a command window anywhere and type php -v should be working.
Good luck.
I installed php5 on monday and it was working with no problems and it's been working up until today when I tried to do a "php artisan migrate" command in the terminal and it said it wasn't recognized, I have the php5 folder saved in "C:\" and hasn't been moved since installation.
Probably You should append directory path of your php.exe to windows PATH environment variable. But be careful by changing this variables. Some information can be found here: http://www.itechtalk.com/thread3595.html or just use Google for more examples.
Kindly try php -v from the command prompt. If you get something like PHP 5.6.10 as output, then your php exists in your path.
In case your PATH is not set, you can use the SET command to set your PHP for that particular instance. Or you can go to My Computer --> Properties --> Advanced --> Environment Variables and append your php directory to the PATH variable.
Thanks!
I reinstalled wamp and in doing so moved my old wamp folder to the desktop forgetting that I had used the wamp php file as my environment path. Ty for all your suggestions
I have a web accessible PHP script that is using a shell command to drop PDFs to text. I installed Poppler, and am using pdftotext, via MacPorts. I am able to run the command successfully from the CL, and when supplying the full path within the PHP script to '/opt/local/bin/pdftotext'. So, I know that my $PATH is correct and the permissions are sufficient, yet I am still getting an exit status of 127: Command Not Found, when attempting to do simply 'pdftotext' in the exec().
I have tried the answers from How do I add paths to the Apache PATH variable? and http://lists.apple.com/archives/macos-x-server/2008/Sep/msg00433.html. I modified both the /etc/paths and /etc/profile, and added /etc/paths.d/macports all pointing to '/opt/local/bin'. setenv, apache_setenv, etc all had no effect also.
I am using a MAMP (1.9 I think) install for my local development, OSX 10.6, PHP 5.3.5, all a little behind I know :-) ... my $PATH is modified to point to the MAMP bin/php
/etc/paths.d/macports will influence on PATH variable for macports, not for the Apache. You probably need to add /etc/parhs.d/apache (or else) to do what you need.
Edit: also check this and this threads for solutions. It is somewhat outdated but still can help.