Download the PHP package sirmonti/simplehttp without Composer

On this page you can find all versions of the php package sirmonti/simplehttp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package simplehttp

simpleHTTP - Simple HTTP client library

Wrapper around file_get_contents function to simplify HTTP and HTTPS connections

Description

Wrapper class around file_get_contents function. This class is not intended to compete with full featured network frameworks, as Guzzle or Swoole, but to provide a simple and convenient solution to use web services or access web resources

Installation

Via composer

This class does not have any external dependency, which means you don't need to do a full installation, you can simply download and drop simpleHTTP.php file in your project folder.

Features

Basic usage

This is only a brief explanation, the file simpleHTTP.md provide a more extensive method reference.

Complete documentation can be found Here.

You create an object of the simpleHTTP class. The constructor has two parameters, the exception level and the remote certificate validation.

Here we create an object with an exception level 2 and certificate validation disabled:

The certificate validation is a boolean flag that enable or disable the validation of the remote certificate on https connections. If the validation is enabled, if the remote site has a bogus certificate (expired, autosigned or for another domain) the connection will be aborted and an error will be fired. In disabled, the error will be ignored and the connection will be executed normally.

About the exception levels, there are three levels:

Default values is exception level 1 and certificate validation enabled.

Supported methods are: GET, POST, PUT, HEAD, DELETE and OPTIONS. The request call return the request body and the other data, like response headers, are stored internally and can be retrieved.

Here, a basic example

This library can return responses in PSR7 format, but is neccesary to have a third party library installed. Currently, HttpSoft, Nyholm, Guzzle, Laminas-diactoros and Slim are supported. simpleHTTP detects which one is installed and will fire an error if none is installed.

PSR7 responses are useful because the main PHP frameworks use this format.

Example getting a PSR7 response

Examples

There are more examples in examples folder.

This is the most simple usage:

As you see, the object execute direct requests providing the URL.

Here, and example configuring exceptions and certificate acceptance

Here, a POST with a JSON encoded body

And here, a POST with an image as data body

But, What if you need to add an authentication header?

But, If we need an extra header only in a specific request?

The requests from this class use "simpleHTTP/7.0" as user agent. You can set your own one

Here, a PUT request example

But, How I can get the response headers and result status?

This code will produce this output

LICENSE

This library is licensed under MIT LICENSE


All versions of simplehttp with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sirmonti/simplehttp contains the following files

Loading the files please wait ....