I just installed Composer on OS X 10.8 and am now trying to use it to install something else and it turns out my terminal is running php 5.3... In XAMPP I have 5.5, so I would like to just use that version in Terminal as well. I tried creating a .bash_profile in my home directory with
export PATH=/Applications/XAMPP/xamppfiles/bin/php-5.5.11/bin:$PATH
but that wouldn't work; which php still returns /usr/bin/php. What am I missing here? Much thanks in advance.
Here is my working Environment Path
export PATH="/Applications/XAMPP/xamppfiles/bin:$HOME/.composer/vendor/bin:/usr/local/sbin:$PATH"
Remember to wrap the path with double quotes and also close all terminal before checking the php version using
php -v or which php
If you aren't using a bash shell, then changing the bash_profile won't make a difference. bash apparently wasn't always the default, so on my mac, I am using .tcsh. I don't know why it uses one over the other, it has just always been that way (been upgrading macs since OS X 10.0). So on mine I have a .tcshrc file which operates like the bash_profile. In there I have
alias php /Applications/MAMP/bin/php/php5.6.7/bin/php
which you would obviously have to adjust to your own path and version, but you get the point.
Related
I want to use PHP IntelliSense while using WSL environment but VScode is unable to find PHP path. What I should do fix this? I searched for some info but I only see scripts but none worked for me.
Try bash -c "php". WSL exposes a bash.exe binary on Windows, and if everything is correct it will already be in the environment variables, just by invoking it as bash - At least here, where I am using WSL2 with Ubuntu 20.04.
You try also, wsl -- "php" or wsl --exec "php".
UPDATE: Forget what I said above !!
Use the Remote - WSL extension . I believe you're already using it.
Add the following directive to the settings.json file:
"php.validate.executablePath":"php"
the php binary must be properly available in $PATH on the Linux side.
And on Windows you need to have the path of the php windows version binary in the system environment variables, so that when you happen to be editing PHP files in the Windows File System - Not using the WSL remote - it uses the same binary.
This way you will have a VSCode that, when you are remote in WSL will use the proper lecture, being the same for when you are in Windows.
The fix for me was to download php for Windows into the folder c:\php and specify in Visual Studio Code settings.json:
"php.executablePath": "c:\\php\\php.exe",
I also added it to my Windows PATH environment variable.
I want to config Visual Studio Code (VSC) to work with php on linux (Ubuntu).
I installed xammp for this purpose and I don't know where to point this parameter on VSC php.validate.executablePath
On windows the config path has to be like this: "php.validate.executablePath": "c:/php/php.exe"
Could you give me the full path to configure it properly ON LINUX?
Regards
This answer may change based on what flavor of Linux/Unix you are using, but if you are using Ubuntu like me, this is how I did it.
First and foremost, I know you're using XAMPP, but do exactly what the error message says and install PHP7. You can do so by running sudo apt-get install php.
I know that goes against intuition. At first I thought "I have XAMPP installed, which installed PHP. Why do I need to install PHP?" XAMPP only includes the PHP runtime executables. In order to do development with PHP, you need to install the full environment. XAMPP will continue to use its built-in version.
Once the install is completed, follow these steps:
Execute whereis php. Example output below:
php: /usr/bin/php7.0 /usr/bin/php /usr/lib/php /etc/php /usr/share/php7.0-json /usr/share/php7.0-opcache /usr/share/php /usr/share/php7.0-readline /usr/share/php7.0-common /opt/lampp/bin/php /usr/share/man/man1/php.1.gz
In Visual Studio Code, click the cog in the bottom left corner and select Settings. On the right-hand pane, insert the following code. The version-agnostic path is used here:
"php.validate.executablePath": "/usr/bin/php"
Press Control+S or click File -> Save
The final settings file should look like this:
// Place your settings in this file to overwrite the default settings
{
// Snip... other configurations overrides
// Points to the PHP executable.
// Use the version-agnostic value from the "whereis php" command above.
"php.validate.executablePath": "/usr/bin/php"
}
For me is "/opt/lampp/bin/php" (I have xampp on Linux Mint; to find out write in terminal: "whereis php")
I'm using Mac OS X (10.11.6) with MAMP PRO 3 and PHP 5.6.10. I've setup the PATH in .bash_profile and everything looks fine.
When I do which php in the terminal I get the following correct path:
/Applications/MAMP/bin/php/php5.6.10/bin/php
Now I'm trying to execute an exec-command with PHP along the lines of the following example:
exec('which php');
This returns /usr/bin/php and therefore is wrong, I want it to use the other version too.
My MAMP related things from .bash_profile:
export PATH=/Applications/MAMP/bin/php/php5.6.10/bin:$PATH
export PATH=/Applications/MAMP/Library/bin/:$PATH
What am I missing?
If i go to localhost/xampp i see php version 5.5.9;
If i check from windows command line php-v i get 5.3.28.
If i check from windows command line c:\xampp\php\php -v i get 5.5.9.
I am not able to find in computer where this php v5.3.28 is installed. It is also not on the PATH variable. It is default php version. How to find it?
Use php -i > yourfile.txt. You will find a lot of information there. Look for "extension_dir"; it will probably point you in the right direction.
I am sorry, for easy question. The answer is to use windows folders search and search for string "php". AS results many files are outputed. Part of them belongs to xampp installation. One folder named "C:\Program Files (x86)\IIS Express" contains this 5.3.28 version of php.
I am using ffmpeg on Mac OSX 10.7.3 in MAMP through PHP's exec() command, I have an absolute path set to call ffmpeg, e.g.
/opt/local/bin/ffmpeg -i "/sample.avi"
But I receive the following error -
dyld: Library not loaded: /opt/local/lib/libjpeg.8.dylib Referenced from: /opt/local/lib/libopenjpeg.1.dylib Reason: Incompatible library version: libopenjpeg.1.dylib requires version 13.0.0 or later, but libJPEG.dylib provides version 12.0.0
N.B. ffmpeg was installed through Macports.
It works from the command line.
What to do?
EDIT
I've reopened this - originally thought shell_exec() solved the issue, but infact it should be called differently - and I didn't realise until investigating further today. Here is my code using shell_exec and still giving the error above:
$cmd = '/opt/local/bin/ffmpeg -h';
$cmd = escapeshellcmd($cmd) . ' 2>&1';
$output = shell_exec($cmd);
var_dump($output);
The problem is that the DYLD_LIBRARY_PATH is set in MAMP and I've installed ffmpeg via macports.
This might not be the best fix but it has me up and running for now:
In the /Applications/MAMP/Library/bin/envvars file and comment the following lines as below:
#DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
#export DYLD_LIBRARY_PATH
and restart Apache
Commenting out the line #DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH" will work in the short term but it could break other things, since you're removing the line that MAMP uses to tell the server where it keeps its libraries.
A better solution would be to change the line to this:
DYLD_LIBRARY_PATH="/usr/local/lib:/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
so that you're just prepending /usr/local/lib: to the already-given path. This tells Apache to look in /usr/local/lib first, and then if that doesn't work, to look in /Applications/MAMP/Library/lib.
So if you install something via, say, Brew and there are two versions, it'll look in the one you installed with Brew first, before it uses whatever came with MAMP, which is more likely to be out of date. But if it's something that only came with MAMP, that you didn't install separately or that is MAMP-specific, you won't break it.
Ensure PHP's exec is using the same shell as you, when you use the commandline.
Probably shell_execÂDocs helps.
See as well php shell_Exec not working while the command works in shell.