简体   繁体   English

如何在 Ubuntu 中安装 Requests for PHP?

[英]How to install Requests for PHP in Ubuntu?

How to install Requests for PHP ( http://requests.ryanmccue.info/ ) on Ubuntu 14.04?如何在 Ubuntu 14.04 上安装 Requests for PHP ( http://requests.ryanmccue.info/ )?

I have downloaded package with command:我已经用命令下载了包:

$ wget https://github.com/rmccue/Requests/tarball/master -O - | tar xzv

In Phyton next step would be:在 Phyton 中,下一步将是:

$ sudo python setup.py install

What command would I use for PHP?我会为 PHP 使用什么命令?

If you install via composer , which I recommend you do, you can then include it just by including the 'autoload.php' that composer generates for you.如果您通过composer安装,我建议您这样做,然后您可以通过包含 composer 为您生成的“autoload.php”来包含它。 Usually from your project root通常来自您的项目根目录

require 'vendor/autoload.php'

but that will depend on the structure of your project.但这将取决于您的项目结构。 Then you're freely able to use然后你就可以自由使用

Requests::get($args); // or, of course, any of the other functions

from within your project.从您的项目中。

Unless it's a compiled PHP extension, there is no installation step for PHP libraries.除非它是已编译的 PHP 扩展,否则没有 PHP 库的安装步骤。 You download the files, you put them in a folder, you require the file you just downloaded.您下载文件,将它们放在一个文件夹中,您require刚刚下载的文件。 Typically you make those dependencies part of your PHP project instead of installing them "globally".通常,您将这些依赖项作为 PHP 项目的一部分,而不是“全局”安装它们。 Composer was created to simplify that process and help you manage dependencies. Composer旨在简化该过程并帮助您管理依赖项。 If you don't use it, it's up to you where to put those files and where to require them from.如果您不使用它,则由您决定将这些文件放在哪里以及从哪里require它们。

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

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