简体   繁体   English

如何使用终端安装PHP(MAMP)的插件和库?

[英]How do I use terminal to install plugins and libraries for PHP (MAMP)?

Can you walk me through the installation of a library for php, specifically what each terminal command does? 你能指导我完成php的库安装,特别是每个终端命令的作用吗?

I have been learning web development for 6 months and it is time I need the console / terminal. 我已经学习了6个月的Web开发,现在是时候我需要控制台/终端了。 I can't find any beginner walkthrough of using the terminal to add libraries and plugins to PHP. 我找不到任何使用终端向PHP添加库和插件的初学者演练。 There are a lot of tutorials for specific steps or errors, but none start to finish. 有很多特定步骤或错误的教程,但没有一个开始完成。


If you want specifics to make your example concrete, here is what I am trying to install: 如果你想让细节具体化,那么我正在尝试安装:

The library I am installing: http://code.google.com/p/phpquery/ . 我正在安装的库: http//code.google.com/p/phpquery/

My directory for PHP on MAMP: /Applications/MAMP/bin/php/php5.3.6/bin 我在MAMP上的PHP目录:/Applications/MAMP/bin/php/php5.3.6/bin


Thanks! 谢谢!
Don

edit : I figured out my specific issue, but I don't think I really understand what I did, so I can't repeat it by myself in any other situation. 编辑 :我想出了我的具体问题,但我不认为我真的理解我做了什么,所以我不能在任何其他情况下自己重复。 This thread can help a lot of new terminal users including myself. 这个线程可以帮助很多新的终端用户,包括我自己。 The type of response I am looking for would go like this: 我正在寻找的响应类型如下:

Step 1: Open your terminal. 第1步:打开终端。 (This is an alternative way to navigate and execute commands on files on your computer). (这是在计算机上的文件上导航和执行命令的另一种方法)。

Step 2: Find out where MAMP is installed however you like. 第2步:找出你喜欢的MAMP安装位置。 Then go to your terminal, and type in cd followed by the path. 然后转到您的终端,输入cd然后输入路径。 cd stands for current directory and tells your terminal where it should execute its commands. cd代表当前目录,告诉终端应该在哪里执行命令。 The command you use will be very similar to this cd /Applications/MAMP . 您使用的命令与此cd /Applications/MAMP非常相似。 This will make your current directory MAMP. 这将使您当前的目录MAMP。

Step 3: You are adding a library to PHP. 第3步:您正在向PHP添加库。 So you need to go to the PHP folder in MAMP.... (please help us from this part!) 所以你需要去MAMP中的PHP文件夹....(请从这部分帮助我们!)

I just checked and it is available in pear channels. 我刚检查过,它可以在梨形通道中使用。

# this is from their site
pear channel-discover phpquery-pear.appspot.com  
pear install phpquery/phpQuery

Of course, for Mac using MAMP, you would use commands like this: 当然,对于使用MAMP的Mac,你可以使用这样的命令:

/Applications/MAMP/bin/php5/bin/pear install [package]

So for PHPQuery, try this: 所以对于PHPQuery,试试这个:

/Applications/MAMP/bin/php5/bin/pear channel-discover phpquery-pear.appspot.com
/Applications/MAMP/bin/php5/bin/pear install phpquery/phpQuery

Same method should apply to pecl extensions as well. 同样的方法也应该适用于pecl扩展。

EDIT 编辑

I personally just installed it on mine to test, here were my results: 我个人刚刚将它安装在我的测试中,这是我的结果:

$ /Applications/MAMP/bin/php5/bin/pear channel-discover phpquery-pear.appspot.com
Adding Channel "phpquery-pear.appspot.com" succeeded
Discovery of channel "phpquery-pear.appspot.com" succeeded
$ /Applications/MAMP/bin/php5/bin/pear install phpquery/phpQuery
downloading phpQuery-0.9.5.386-pear.tgz ...
Starting to download phpQuery-0.9.5.386-pear.tgz (100,990 bytes)
......................done: 100,990 bytes
install ok: channel://phpquery-pear.appspot.com/phpQuery-0.9.5.386

This should work with any PEAR or PECL extension. 这适用于任何PEAR或PECL扩展。 Check out this page for a list of PEAR packages . 查看此页面以获取PEAR包列表

EDIT 2 编辑2

Make sure /Applications/MAMP/bin/php5/lib/php is in your include path! 确保/Applications/MAMP/bin/php5/lib/php在你的包含路径中! That is where phpQuery.php will be located once you've downloaded the PEAR packages properly with MAMP. 一旦你用MAMP正确下载了PEAR包,那就是phpQuery.php所在的位置。


EDIT 3 编辑3

Per cshu's comment, he mentioned that these packages are no longer maintained and that you should use this instead: 根据cshu的评论,他提到不再维护这些包 ,你应该使用它:

$ /Applications/MAMP/bin/php5/bin/pear channel-discover pear.querypath.org 
$ /Applications/MAMP/bin/php5/bin/pear install querypath/QueryPath

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM