问题描述
我已安装MAMP.现在,我正在尝试从命令行运行脚本,但似乎无法使其正常工作.
I have MAMP installed. Now I am trying to run a script from the command line, but I can't seem to get it to work.
如何设置环境,以便可以从命令行运行脚本并使用随MAMP安装的PHP版本?
How should I set up my environment so that I can run a script from the command line and use the PHP version I installed with MAMP?
更新:我同意下面的jjeaton,:
Update: I agree with jjeaton below, here is a nice solution of creating an alias to MAMP's PHP:
# add this to your ~/.bash_profile
alias phpmamp='/Applications/MAMP/bin/php/php5.3.6/bin/php'
现在您可以从命令行使用它:
Now you can use it from the command line:
$ phpmamp --help
推荐答案
请注意,对于MAMP版本2.0.5,路径已更改.现在是以下之一:
Please note that with version 2.0.5 of MAMP, the path has changed. It is now one of the following:
/Applications/MAMP/bin/php/php5.2.17/bin/
/Applications/MAMP/bin/php/php5.3.6/bin/
因此,添加MAMP的php命令的命令应该看起来像这样:
Therefore the command to add MAMP's php command should probably look like this:
export PATH=/Applications/MAMP/bin/php/php5.2.17/bin/:$PATH
或类似这样(取决于您要使用的PHP版本):
or like this (depending on which version of PHP you want to use):
export PATH=/Applications/MAMP/bin/php/php5.3.6/bin/:$PATH
这篇关于如何使用MAMP从命令行运行PHP脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!