在 MAMP 上安装 PEAR

发布于 2024-10-28 03:43:05 字数 310 浏览 0 评论 0原文

我正在使用 MAMP 进行开发。我一直无法让 PEAR 工作。 MAMP 文档和论坛似乎没有答案。在MAMP论坛上提问的人似乎都没有回复。

以前我在 MAMP 上开发了系统,并且只使用 PEAR 来处理邮件,所以我让它在服务器上运行一次,而不是在 MAMP 中运行。我现在想使用更多的 PEAR。

谁能给我一个白痴指南来让它继续下去。我可以访问终端并输入命令行,但是,我并不真正了解发生了什么,因此当事情停止或抛出错误时,我必须提出更多问题。我尝试过在互联网上找到的各种东西,但到目前为止都失败了。

MAMP 版本为 1.9.5 Mac OS 10.6.7

I am using MAMP for development. I have never been able to get PEAR to work. The MAMP documentation and forums seem not to have the answers. Everybody who asked on the MAMP forum seems to have no replies.

Previously I have developed the systems on MAMP and only used PEAR for mail so I got it working once on the server rather than in MAMP. I want to use more of PEAR now.

Can anybody give me an idiots guide to getting it going. I can access terminal and type command lines, however, I don't really understand what's going on so when things stop or throw errors I have to ask more questions. I have had a go with various things found on the internet but failed so far.

MAMP is version 1.9.5 Mac OS 10.6.7

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

送君千里 2024-11-04 03:43:05

@Marcelo Rodrigo 的回答很棒!我很高兴他提供了他的消息来源。通过跟踪他的消息来源,我找到了以下信息。


在 MAMP 上安装 PEAR

为了让 PEAR 与 MAMP 一起工作,请运行以下命令。请注意,有适用于 MAMP v1.xx 和更新版本的命令。找出您正在运行的版本。另请注意,PHP 版本有所不同。确保以下命令中的版本是您实际使用的版本。 MAMP 允许您更改版本。您可以通过打开 MAMP > 查看服务器> PHP。

注意:

这对某些人来说可能是显而易见的,但您应该首先停止 MAMP。否则你可能会得到一些奇怪的错误。

1) 更改目录权限,以便您可以执行其中的文件:

MAMP v2.xx

chmod 774 /Applications/MAMP/bin/php/php5.4.4/bin/pear
chmod 774 /Applications/MAMP/bin/php/php5.4.4/bin/php

MAMP v1.xx

chmod 774 /Applications/MAMP/bin/php5.3/bin/pear
chmod 774 /Applications/MAMP/bin/php5.3/bin/php

2) 设置别名以避免输入整个路径。

每次您想要访问 pear 时,您都必须输入“/Applications/MAMP/bin/php5.3/bin/pear”。输入“pear”是指您的 mac 上已安装的内容,而不是 MAMP 的安装内容。 (这仅适用于当前会话。对于永久别名,请将以下命令放入 ~/.bash_profile 文件中。 这是有关如何执行此操作的教程。)

MAMP v2.xx

alias mpear="/Applications/MAMP/bin/php/php5.4.4/bin/pear"

MAMP v1.xx

alias mpear="/Applications/MAMP/bin/php5.3/bin/pear"

3) 在php5 和 php5.3 文件夹(MAMP v2.xx 不需要):

Pear 对其版本感到困惑,因为它安装在 php5.3 和 php5 目录中

当您升级 pear 时,它将创建一个新的 /Application/MAMP /bin/php5 目录并在 php5.3 和 php5 文件夹之间传播文件。使用下面的代码在两个文件之间建立链接,以便它们充当一个文件。 有关“ln”命令的更多信息。资料来源:@Marcelo Rodrigo 的帖子

ln -s php5.3 php5

4) 检查以确保 pear正在工作:

mpear -V

5) 现在升级 pear:

mpear channel-update pear.php.net
mpear upgrade pear

6) 再次检查是否正确升级了 pear

mpear -V


安装 PHPUnit

您不需要安装 PHPUnit。如果 mpear -V 对您有用,那么您就已经在 MAMP 上安装了 PEAR。对于我的开发环境,我需要 PHPUnit 用于单元测试,所以我想既然我们已经有了 PEAR,我应该包括一个安装 PHPUnit 的教程。仅当您需要 PHPUnit 时才执行此操作。如果您不知道它是什么,则不需要它。

运行以下命令:

1) 安装 PHPUnit:

注意: 下面我使用“mpear”,它实际上是我在上面步骤 2 中设置的别名。您可以简单地使用“/Applications/MAMP/bin/php5.3/bin/pear”代替它。

mpear config-set auto_discover 1
mpear install pear.phpunit.de/PHPUnit

来源:http://www.phpunit.de/manual/current/en/ Installation.html

2) 允许 MAMP 使用 PHPUnit

MAMP 的 phpunit 安装与默认 phpunit 位置链接。 (不适用于 Mountain Lion,请参阅步骤 2a)

sudo ln -s /Applications/MAMP/bin/php5/bin/phpunit /usr/local/bin/phpunit

**2a) 仅适用于 Mountain Lion - 在 MAMP 的 php.ini 和 /etc 中的 php.ini 之间创建符号链接

sudo ln -s /Applications/MAMP/bin/php/php5.4.4/conf/php.ini /etc/php.ini

如果显示文件存在,请备份/etc/php.ini 并删除它。

3) 确保它正常工作

phpunit --version

有关安装 phpunit 的详细信息,请查看:


来源:

@Marcelo Rodrigo's answer is great! And I'm glad he included his sources. By following sources of his sources I was able to find the information below.


Install PEAR on MAMP

In order to get PEAR working with MAMP run the following commands. Notice there are commands for MAMP v1.x.x and for newer versions. Find out what version you are running. Also, notice that the PHP versions differ. Make sure the version in the commands below is the one you are actually using. MAMP allows you to change versions. You can check by opening MAMP > Server > PHP.

NOTE:

This may be obvious to some, but you should stop MAMP first. Otherwise you might get some strange errors.

1) Change the directory permissions so you can execute files within them:

MAMP v2.x.x

chmod 774 /Applications/MAMP/bin/php/php5.4.4/bin/pear
chmod 774 /Applications/MAMP/bin/php/php5.4.4/bin/php

MAMP v1.x.x

chmod 774 /Applications/MAMP/bin/php5.3/bin/pear
chmod 774 /Applications/MAMP/bin/php5.3/bin/php

2) Setup an alias to avoid typing the whole path.

Every time you want to access pear you have to type "/Applications/MAMP/bin/php5.3/bin/pear". Typing "pear" referes to what is installed on your mac already and not MAMP's install. (This only apply for the current session. For a permanent alias, place the command below in your ~/.bash_profile file. Here is a tutorial on how to do that.)

MAMP v2.x.x

alias mpear="/Applications/MAMP/bin/php/php5.4.4/bin/pear"

MAMP v1.x.x

alias mpear="/Applications/MAMP/bin/php5.3/bin/pear"

3) Make a link between php5 and php5.3 folders (Not Needed for MAMP v2.x.x):

Pear gets confused about its version because it installs in both php5.3 and php5 directory

When you upgrade pear it will create a new /Application/MAMP/bin/php5 directory and spread files between php5.3 and php5 folders. Use the code below to make a link between the two file so they act as one. More info about "ln" command. Source: @Marcelo Rodrigo's post

ln -s php5.3 php5

4) Check to make sure pear is working:

mpear -V

5) Now upgrade pear:

mpear channel-update pear.php.net
mpear upgrade pear

6) And check again to see if it upgraded pear correctly

mpear -V


Install PHPUnit

You do not need to install PHPUnit. If mpear -V worked for you, then you are done installing PEAR on MAMP. For my development environment I needed PHPUnit for unit testing, so I figured I would include a tutorial to install PHPUnit now that we have PEAR working. Only do this if you need PHPUnit. If you don't know what it is, you don't need it.

Run the following commands:

1) Install PHPUnit:

NOTE: Below I am using "mpear" which is actually an alias I setup in step 2 above. You could simply use "/Applications/MAMP/bin/php5.3/bin/pear" in its place.

mpear config-set auto_discover 1
mpear install pear.phpunit.de/PHPUnit

Source: http://www.phpunit.de/manual/current/en/installation.html

2) Allow MAMP to use PHPUnit

Link your MAMP's install of phpunit with the default phpunit location. (Doesn't work with Mountain Lion, instead see step 2a)

sudo ln -s /Applications/MAMP/bin/php5/bin/phpunit /usr/local/bin/phpunit

**2a) For Mountain Lion Only - Create a symobolic link between MAMP's php.ini and the php.ini in /etc

sudo ln -s /Applications/MAMP/bin/php/php5.4.4/conf/php.ini /etc/php.ini

If it says files exists, make a backup of /etc/php.ini and delete it.

3) Make sure it works

phpunit --version

For details about installing phpunit check out:


Sources:

凹づ凸ル 2024-11-04 03:43:05

如果您只想让 phpunit 工作,请在 MAMP 1.9.5 的新副本上使用以下命令:

cd /Applications/MAMP/bin
ln -s php5.3 php5
php5/bin/pear channel-discover pear.phpunit.de
php5/bin/pear channel-discover components.ez.no
php5/bin/pear channel-discover pear.symfony-project.com
php5/bin/pear channel-update pear.php.net
php5/bin/pear upgrade pear
php5/bin/pear install phpunit/PHPUnit
ln -s /Applications/MAMP/bin/php5/bin/phpunit /usr/local/bin/phpunit
phpunit --version

完成。

上述代码修复了以下问题:

Bug 1:
pear 对它的版本感到困惑,因为它安装在 php5.3 和 php5 目录中

Pear 更新升级并从 /Applications/MAMP/bin/php5.3/pear 安装,但它将创建一个新的 /Application/MAMP/bin/php5目录并在 php5.3 direct 和新的 php5 目录之间传播文件,并且对它是什么版本感到非常困惑。

使固定:
ln -s php5.3 php5

我认为如果您使用的是 PHP 5.2,那么使用 ln -s php5.2 php5 应该同样有效,但我还没有测试过这个

问题 2:
pear 已经过时了,

这是 MAMP 团队可以理解的,问题实际上是由于 Bug 1 很难进行升级

来源:http://forum.mamp.info/viewtopic.php?f=6&t=11102

If you just want phpunit to work, use the following commands on a fresh copy of MAMP 1.9.5:

cd /Applications/MAMP/bin
ln -s php5.3 php5
php5/bin/pear channel-discover pear.phpunit.de
php5/bin/pear channel-discover components.ez.no
php5/bin/pear channel-discover pear.symfony-project.com
php5/bin/pear channel-update pear.php.net
php5/bin/pear upgrade pear
php5/bin/pear install phpunit/PHPUnit
ln -s /Applications/MAMP/bin/php5/bin/phpunit /usr/local/bin/phpunit
phpunit --version

Done.

The above code fixes the following issues:

Bug 1:
pear gets confused about its version because it installs in both php5.3 and php5 directory

Pear updates upgrades and installs from /Applications/MAMP/bin/php5.3/pear, but it will create a new /Application/MAMP/bin/php5 directory and spread files between the php5.3 direct and the new php5 directory and get very confused about what version it is.

Fix:
ln -s php5.3 php5

I think that if you are using PHP 5.2 then using ln -s php5.2 php5 should work equally well but I haven't tested this

Issue 2:
pear is out of date

this is understandable of the MAMP team, the problem really was that it was difficult to do a upgrade because of Bug 1

Source: http://forum.mamp.info/viewtopic.php?f=6&t=11102

滥情哥ㄟ 2024-11-04 03:43:05

我最近发现以下链接正确设置了我的 MAMP 2.1.1 运行:

PEAR Version: 1.9.4
PHP Version: 5.4.4
Zend Engine Version: 2.4.0

尝试:

sudo /Applications/MAMP/bin/php/php5.4.4/bin/pear config-set auto_discover 1
sudo /Applications/MAMP/bin/php/php5.4.4/bin/pear install pear.phpunit.de/PHPUnit

要使其在命令行上随处可用,您需要在本地 bin 中创建一个指向 phpunit 的软线。

sudo ln -s /Applications/MAMP/bin/php/php5.4.4/bin/phpunit /usr/local/bin/phpunit

现在尝试:

 phpunit --version
  1. 确认它有效,从这里尝试:/Applications/MAMP/bin/php/php5.4.4/bin/
  2. 确认符号链接有效。在其他地方尝试一下,例如 ~//

如果它们都有效,那么您就可以开始编码了。

来源/来源:Enej Bajgoric Web 开发人员,CTLT UBC 温哥华加拿大 http://blogs.ubc.ca/enej/2012/10/01/installing-phpunit-on-mamps/

I recently found the following link correctly setup my MAMP 2.1.1 running:

PEAR Version: 1.9.4
PHP Version: 5.4.4
Zend Engine Version: 2.4.0

Try:

sudo /Applications/MAMP/bin/php/php5.4.4/bin/pear config-set auto_discover 1
sudo /Applications/MAMP/bin/php/php5.4.4/bin/pear install pear.phpunit.de/PHPUnit

To make it available on the command line everywhere you need to create a soft-line to phpunit in your local bin.

sudo ln -s /Applications/MAMP/bin/php/php5.4.4/bin/phpunit /usr/local/bin/phpunit

Now try:

 phpunit --version
  1. Confirm it works try it from here: /Applications/MAMP/bin/php/php5.4.4/bin/
  2. Confirm the symlink worked. Try it somewhere else like ~/ or /.

If they both worked you are ready to code.

SOURCE/CREDIT: Enej Bajgoric Web Developer, CTLT UBC Vancouver Canada at http://blogs.ubc.ca/enej/2012/10/01/installing-phpunit-on-mamps/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文