Download the PHP package sirmonti/shttp without Composer

On this page you can find all versions of the php package sirmonti/shttp. 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 shttp

SHTTP - Simple HTTP client library

Static version rapper 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.

This class is the static version of simpleHTTP which means there is no need to create an object, methods can be called directly.

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 SHTTP.php file in your project folder.

Features

Basic usage

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

Complete documentation can be found Here.

There are four global parameters: exception level, certificate validation flag, extra HTTP headers and Certificate Authentication.

Certificate validation flag is set via "verifCERT" boolean property, exception level via setExceptionLevel() method, extra HTTP headers via setExtraHeaders() method and Certificate Authentication via setAuthCert() method.

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 faulty 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.

There are three exception 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, the most basic example of using this class

Here, we modify certificate validation and exception level

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. SHTTP 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.

The most simple usage is to call requests directly

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 "SHTTP/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 shttp 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/shttp contains the following files

Loading the files please wait ....