I am running on a Windows machine. I installed WT-NMP and I am trying to install composer.phar. No matter from what folder I run this
php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
it always installs in the /bin/php-5.5.8/ instead of the /www/project folder where I want it. Because of this, whenever I try to run
composer update
I receive an error that it can't find the composer.json file (because the json file is in www/project but it is searching for it in /bin/php-5.5.8 instead). I tried everything that I could think of but I can't get it to work.
Any help is appreciated. Thanks!
You could try to find out the reason why it does what you don't like, but the installer script essentially only checks some settings of the PHP used before downloading the .phar file because debugging things inside the .phar is problematic, i.e. it would be a support nightmare if you'd simply download the pure .phar and try to run it if your PHP is unable to do so.
Long story short: You can simply copy or move the downloaded composer.phar to any location you like, and it will work.
you only need to specify where you want to install composer by changing PHP`s current working directory with chdir:
C:\WT-NMP\bin\php.bat -r "chdir('C:/WT-NMP/WWW'); eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
an odd solution to an odd installation method ;)
Related
i'm trying to set the certain path for the php extension in my vscode (using linux)
i started installing the XAMPP
and after it..i tried to use the extension writing some php scripts(php extension INTELLISENSE and DEBUG), but the extension is not working properly and it's showing that error:
Cannot validate since /usr/bin/php is not a valid php executable. Use the setting 'php.validate.executablePath' to configure the PHP executable.
i tried to set it using que path which is provided by vscode documentation, but it's still no working.
Can anyone help me !! please!!!
I found a solution, typing in terminal
'whereis php'
that returns the absolute path for set it in the vscode extension
/opt/lampp/bin/php
Then, setting the path in the follow line
php.validate.executablePath: "/opt/lampp/bin/php",
So, I hope this solution is helping someone behind the screen.
Php path in windows
Typing in terminal
where php
And it'll gives the path as (in my case)
C:\xampp\php\php.exe
Just extending the answer by #Reinaldo Duguet with a ton of thanks to him !
If you are using Xampp, the PHP path can be found by running the local server and then typing localhost in the browser. This will open the Xampp dashboard. Click on phpinfo() and there you will get the exact path shown as
Configuration File (php.ini) Path = /opt/lampp/etc
Please note that the path may very as per the PHP installation in your system. So you may have to use the respective path shown with above ways.
Then, to let VSCode know this path, open settings in VSCode and search for "PHP debug" and click on the PHP > Debug:Executable Path setting
Add the following line at the first place after "{" telling VSCode where PHP is installed in the system.
"php.validate.executablePath": "/opt/lampp/etc",
If you are using Xampp, the PHP path can be found by running the local server and then typing
the correct version C:/xampp/php/php.exe
XAMPP isn't the best option for linux and i wouldn't recommend it.
Assuming this is not the problem, here is how to do :
find php executable
whereis php
Check your vscode installation. You want to make sure it's not using flatpak (it runs in a container and it would mess up everything)
go in vscode settings, search for php and set "php.debug.executablePath": "/your path/php"
If it still doesn't work, this might be a permission problem. Then :
copy the php executable in your user folder
sudo cp original_path/php /your_user_folder/php
add permissions
sudo chmod 777 /your_user_folder/php
If none of above worked, at this point, you may want to use a VM.
I just wanted to add a possibility here that ended up being my issue in case it helps someone else in the future. My issue was that I was using a Debian based distro and installed VSCode through the software app which relies on Snap apparently. Snap runs the programs in a sandbox and prevents them from seeing other locations on the computer. My solution was that I uninstalled the shop version and installed VScode manually via downloading directly from the website. After that, everything works as expected.
I have problem with my PHP and composer. I have set environment variables:
But whenever I call php or composer I get an error:
It's weird, because when I start cmd as an admin it works. But I want it to work always, because its much easier to write cmd to navigation path which opens the command line in exact path I use and don't need to write cd commands every time I need something.
Have you tried installing composer with the Windows GUI? If I remember correctly, it sets up your path variables itself.
https://getcomposer.org/doc/00-intro.md#installation-windows
You could try adding the same path to your user path variables too, in the first box. I guess you're restarting your CMD window?
I am installing composer for laravel installation.but when it want php.exe file i coudn't find it in c:/xampp/php folder.I set up my path variable c:/xampp/php but it is still not working.help me guys.
If xampp has correctly installed, but you are failing to run PHP it is more than possible that you don't have PHP set in your environment paths.
To set this go to;
Start > right click computer > properties > Advanced system settings > Environment Variables.
Under System variables find a variable named PATH, highlight then click Edit... Append the absolute path to your root PHP folder, this could either be xampps located in.
c:/xampp/php/
Press Ok, once you've finished; close down any command prompt windows you may have open. Re-open command prompt and run php -v. Hopefully at this point PHP has responded with it's version and license information.
Make sure you have xampp properly installed.
If you add c:/xampp/php to your PATH while you have a console open, you need to open another console, in order for the PATH to be updated.
i think I have that problem one day, i solved uninstalling xampp server and reinstalling it, but when xampp ask you wich folder to install you need to create a new folder:
C://new folder/xampp/.......
If you install/uninstall multiples xampp or wampp versions for some reasons create storage info in the xampp folder, so creating a new folder solve the problem.
You can use this path:
c:/xampp/php/php.exe
PATH should be a directory, not a file, so you should set it to "c:\xampp\php\", other than"c:\xampp\php\php.exe"
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.
I've just upgraded PHP to the latest version. When I get back to Git, to my command shell, if I execute any PHP function, then I get this error :
sh.exe": php: command not found
I know I have to tell git bash where my new PHP path is, but I don't know how to do so and I can't find anything on Google about that.
EDIT :
I made a confusion you're right : I meant Git BASH by git. Thanks :)
SO here is the function I tried to call when I was dealing with symfony in the root foler of my app :
php app/console dump-sql
then Git BASH sent me the error above.
If you are windows, then following up on halfer's comment, it is required that you add the new
/bin/ directory of the php folder to your PATH.
To do this:
1. Open start menu
2. Right click my computer->properties
3. Click advanced tab -> Environment variables
4. Scroll down in the second listbox for a entry called PATH
5. add this to the end ;C:/%PHP_LOCATION%/bin
where %PHP_LOCATION% is the place that you installed PHP to.
I think you have git and bash confused.
Git is a program that would be running under bash, and isn't directly related to git unless you've gone out of your way to entangle them.
Most likely, the incantation you need is
export PATH=/path/where/php/is:$PATH
And then everything will be working. Note that needs to be the path to the directory, not the binary.
the $PATH at the end is to make sure that you don't clobber your old path.
I had the same error. I found that I needed the environment variable path in this format:
/c/wamp/bin/php/php5.3.13 (instead of C:\wamp\bin\php\php5.3.13)
Using Windows 7 & Git 1.7.10.