How To Install php-http-request2 on Ubuntu 20.04

In this tutorial we learn how to install php-http-request2 on Ubuntu 20.04. php-http-request2 is Provides an easy way to perform HTTP requests

Introduction

In this tutorial we learn how to install php-http-request2 on Ubuntu 20.04.

What is php-http-request2

php-http-request2 is:

PHP5 rewrite of HTTP_Request package (with parts of HTTP_Client). Provides cleaner API and pluggable Adapters:

  • Socket adapter, based on old HTTP_Request code,
  • Curl adapter, wraps around PHP’s cURL extension,
  • Mock adapter, to use for testing packages dependent on HTTP_Request2. Supports POST requests with data and file uploads, basic and digest authentication, cookies, managing cookies across requests, proxies, gzip and deflate encodings, redirects, monitoring the request progress with Observers…

There are three methods to install php-http-request2 on Ubuntu 20.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install php-http-request2 Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install php-http-request2 using apt-get by running the following command:

sudo apt-get -y install php-http-request2

Install php-http-request2 Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install php-http-request2 using apt by running the following command:

sudo apt -y install php-http-request2

Install php-http-request2 Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install php-http-request2 using aptitude by running the following command:

sudo aptitude -y install php-http-request2

How To Uninstall php-http-request2 on Ubuntu 20.04

To uninstall only the php-http-request2 package we can use the following command:

sudo apt-get remove php-http-request2

Uninstall php-http-request2 And Its Dependencies

To uninstall php-http-request2 and its dependencies that are no longer needed by Ubuntu 20.04, we can use the command below:

sudo apt-get -y autoremove php-http-request2

Remove php-http-request2 Configurations and Data

To remove php-http-request2 configuration and data from Ubuntu 20.04 we can use the following command:

sudo apt-get -y purge php-http-request2

Remove php-http-request2 configuration, data, and all of its dependencies

We can use the following command to remove php-http-request2 configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge php-http-request2

References

Summary

In this tutorial we learn how to install php-http-request2 package on Ubuntu 20.04 using different package management tools: apt, apt-get and aptitude.