ref. How to config the internal TM preview browser to run the MAMP PHP engine?
When running PHP scripts with TM cmd+shift+R run command, the internal TM preview browser will use the system installed PHP engine. How can I config the internal TM preview browser to run the MAMP PHP engine instead?
On May 12, 2009, at 4:49 AM, sohdubom wrote:
ref. How to config the internal TM preview browser to run the MAMP PHP engine?
When running PHP scripts with TM cmd+shift+R run command, the internal TM preview browser will use the system installed PHP engine. How can I config the internal TM preview browser to run the MAMP PHP engine instead?
Interesting, was wondering it myself the other day, though mine naturally is using the php I installed, not the apple one.
I think the best way is to not change TM, but to change your environment.
If I run echo phpInfo(); in TM, it shows me my used path is: PhpMate r11069 running PHP 5.2.9 (cli) (/opt/local/bin/php)
Running `which php` in the terminal: /opt/local/bin/php
I suspect yours will be: /usr/bin/php
A few ways to solve it. move /usr/bin/php out of the way, symbolic link to your other php. Or, as I did, add the path the where my other php and tools are...
( This is in ~/.bashrc if you do not have one, make it ) echo $PATH /opt/local/bin:/opt/local/sbin:/Users/me/bin:/usr/bin:/bin:/usr/sbin:/ sbin:/usr/local/bin:/usr/X11/bin
Those work in order, so the ones I want to load first, are first in the list. The first one is where my php is, /opt/local/bin
Hi. yes my path is: PhpMate r11069 running PHP 5.2.6 (cli) (/usr/bin/php)
If I check the path running PhpInfo() through MAMP I get: Configuration File (php.ini) Path : /Applications/MAMP/conf/php5
So I need do configure .bashrc or .profile and add a PATH to: /Applications/MAMP/conf/php5 ?
In the Terminal when I : echo $PATH I get: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin Where is this $PATH set, since I'm not using a .bashrc file in my user home dir
Can I use the .profile file? How could I configure the right path in this case?
Thanx in advance. SohDubom.
On May 14, 2009, at 6:07 AM, sohdubom wrote:
Hi. yes my path is: PhpMate r11069 running PHP 5.2.6 (cli) (/usr/bin/php)
If I check the path running PhpInfo() through MAMP I get: Configuration File (php.ini) Path : /Applications/MAMP/conf/php5
So I need do configure .bashrc or .profile and add a PATH to: /Applications/MAMP/conf/php5 ?
Yes, you do. I believe it is .bash_profile now, after reading some. Though .profile seems supported, probably for compatibility reasons.
In the Terminal when I : echo $PATH I get: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin Where is this $PATH set, since I'm not using a .bashrc file in my user home dir
The default $PATH is set from /etc/profile, which runs around and gets values from /etc/bashrc.
You *do not* want to edit those files.
Can I use the .profile file? How could I configure the right path in this case?
I have never been entirely clear on why you would chose .bash_profile over .bashrc in ~
A doc I found states: To make these changes permanent, add the commands described above to the end of your .cshrc file (for csh and tcsh), .profile file (for sh and ksh), or .bash_profile file (for bash).
Probably .profile works since Apple used to use tcsh a long time ago, and they wanted to maintain a working set of shell prefs for upgrade users.
That implies you should set them in .bash_profile
I have always set them in .bashrc, but I also know they work in .bash_profile. I use both, I actually use .bashrc and then source the .bash_profile.
Remember the earlier entries in the path take precedence over the later ones. If you want the directories you add to your path to take precedence, add them first in the list of colon separated values.
I would do this: pico -w ~/.bash_profile
You will add data to this file, if you add other data, make sure the $PATH is set last in the file, at the bottom.
export PATH=/Applications/MAMP/conf:$PATH
Save the file, control-x then press y, then enter, either close the terminal, open again, or type `source ~/.bash_profile`
Type `echo $PATH` and make sure your new path has /Applications/MAMP/ conf at the front of it. Test again with `which php` and I believe you should see your new location to php being found. TM should now be happy as well.
Please feel free to let me know if this does not work for you. I installed MacPorts php and even added a variant for IMAP, changing my path allowed TM to run the IMAP commands. I wish Apple would just supply a better php, as Apache is fine, but php is far too bare bones to do any serious work.
Thanks Scott,
but still not there yet ...
1. I created the .bash_profile following your instructions: ....then echo $PATH returned: ..../Applications/MAMP/conf:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin ....as expected, but ....which php returned: ..../usr/bin/php
2. and running phpinfo() within TM still points: .... PhpMate r11069 running PHP 5.2.6 (cli) (/usr/bin/php)
any ideas?
On May 14, 2009, at 3:44 PM, sohdubom wrote:
but still not there yet ...
- I created the .bash_profile following your instructions:
....then echo $PATH returned: ..../Applications/MAMP/conf:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/ bin:/usr/X11/bin ....as expected, but ....which php returned: ..../usr/bin/php
- and running phpinfo() within TM still points:
.... PhpMate r11069 running PHP 5.2.6 (cli) (/usr/bin/php)
any ideas?
From the `man which` command
NAME which -- locate a program file in the user's path
This to me leads me to suspect that /Applications/MAMP/conf is not where php really is.
Can you try: $which -a php This will list all the locations of php it knows about.
Can you also do: /Applications/MAMP/conf/php -v and ... file /Applications/MAMP/conf/php and... ls -la /Applications/MAMP/conf
It looks like the MAMP people have decided to store things in some interesting (IMHO) places. Try editing your path to this:
export PATH=/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5/ bin:$PATH
Put that as the last line in your profile, replacing the other one previously.
Thanks Igor and Scott for the great tips,
Since I was previously following Scott's instructions I decided to try his last tip and changed the $PATH to: export PATH=/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5/bin:$PATH
Now when I run phpinfo() in TM I get the right PHP from MAMP: PhpMate r11069 running PHP 5.2.6 (cli) (/Applications/MAMP/bin/php5/bin/php)
note: the strange thing is that when I run phpinfo() from TM, my MAMP server was not running, is it ok?
The echo $PATH now returns: /Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
The which -a php returns: /Applications/MAMP/bin/php5/bin/php /usr/bin/php
On May 15, 2009, at 4:48 AM, sohdubom wrote:
Thanks Igor and Scott for the great tips,
Since I was previously following Scott's instructions I decided to try his last tip and changed the $PATH to: export PATH=/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5/bin: $PATH
Now when I run phpinfo() in TM I get the right PHP from MAMP: PhpMate r11069 running PHP 5.2.6 (cli) (/Applications/MAMP/bin/php5/ bin/php)
Good news, it is working then.
note: the strange thing is that when I run phpinfo() from TM, my MAMP server was not running, is it ok?
Yes, the webserver is just that, a webserver, TM is running php via the command line binary, therefor the webserver does not need to be up.
The echo $PATH now returns: /Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5/bin:/usr/ bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
Looks good to me.
The which -a php returns: /Applications/MAMP/bin/php5/bin/php /usr/bin/ph
Also looks good.
This was a needed change for you, you really want your path to reflect the fact that you have installed a new php. Now when you are in the command line, you can just use `php` instead of the entire path. You now know for sure, you are not ever going to be using the Apple php unless you explicitly tell the shell to do so.
Jibberia had a nice suggestion as well, which would have been a great way to get TM to work how you wanted it right away. However, in the long run, I think best to get your environment variables set and understood.
On May 15, 2009, at 12:44 AM, sohdubom wrote:
Thanks Scott,
but still not there yet ...
- I created the .bash_profile following your instructions:
....then echo $PATH returned: ..../Applications/MAMP/conf:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/ bin:/usr/X11/bin ....as expected, but ....which php returned: ..../usr/bin/php
- and running phpinfo() within TM still points:
.... PhpMate r11069 running PHP 5.2.6 (cli) (/usr/bin/php)
any ideas?
I guess you need to configure this settings in your $HOME/.MacOSX/ environment.plist instead. I think TextMate doesn't use a shell or at least doesn't load your $HOME/.bash_profile file to run those commands.
If the file $HOME/.MacOSX/environment.plist doesn't exist on your home, you can execute the following commands on your Terminal:
mkdir ~/.MacOSX touch ~/.MacOSX/environment.plist open ~/.MacOSX/environment.plist
The last command will launch Property List Editor. If you don't have a line with "PATH" in there, you need to add another item (by clicking "Add Item") of String type, and add the same thing as you've seen on your .bash_profile. If it already exists, you can only put the location of your MAMP php bin directory (which in my case is / Applications/MAMP/bin).
Remember that applications launched by you outside Terminal usually don't read your ~/.bash_profile settings file.
You can find more information about environment.plist on this[1] article, and even a Python application to copy all your environment variables to your environment.plist to keep them in sync.
By the way, it seems you configured wrongly your .bash_profile: you've used /Applications/MAMP/conf instead of /Applications/MAMP/bin.
Hope this helps!
[1] http://www.macosxhints.com/article.php?story=20040715133738459
-- Igor Sutton igorsutton@me.com
sohdubom wrote:
How to config the internal TM preview browser to run the MAMP PHP engine?
TextMate respects the TM_PHP environment variable if it is set. In TM's preferences, choose Advanced > Shell Variables, and add TM_PHP with the full path to the php binary (in your case, probably something like /Applications/MAMP.app/Contents/Resources/bin/php (total guess, I've never used a mamp before)).
HTH
\k
That's quite interesting ... I also found this: http://wiki.macromates.com/Howtos/Requests
But with this approach, only TM will look for MAMP's PHP ... if I want my Terminal to use MAMP's PHP also then changing the .profile file is necessary too.
Thanx again for the tips :-)
jibberia wrote:
sohdubom wrote:
How to config the internal TM preview browser to run the MAMP PHP engine?
TextMate respects the TM_PHP environment variable if it is set. In TM's preferences, choose Advanced > Shell Variables, and add TM_PHP with the full path to the php binary (in your case, probably something like /Applications/MAMP.app/Contents/Resources/bin/php (total guess, I've never used a mamp before)).
HTH
\k