Download the PHP package stubbles/peer without Composer

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

stubbles/peer

Help with socket operations.

Build status

Tests

Latest Stable Version

Installation

stubbles/peer is distributed as Composer package. To install it as a dependency of your package use the following command:

composer require "stubbles/peer": "^10.0"

Requirements

stubbles/peer requires at least PHP 8.2.

Working with URIs

Sometimes it's useful to have a URI wrapped into a class which provides methods to work with this URI. Stubbles Core provides stubbles\peer\Uri for such cases.

New instances can be created via Uri::fromString('ftp://[email protected]/');. The following rules apply:

In order for a uri string to be a valid URI it must adhere to the specification laid out in RFC 3986.

Please note that hostnames will be normalized, which means if the given hostname is e.g. eXAMple.net, it will be normalized to example.net and always returned in normalized form.

For the methods, the following rules apply:

URI instances can only be changed regarding their URI parameters. It is not possible to change the scheme, host, user, password, port, or fragment of the URI.

Working with HTTP URIs

While the basic implementation for URIs already provides useful help when working with URIs, sometimes one needs slightly better support for HTTP URIs. stubbles/peer provides stubbles\peer\http\HttpUri for such cases.

New instances can be created via HttpUri::fromString('http://example.net/');. The following rules apply:

In order for a uri string to be a valid URI it must adhere to the specification laid out in RFC 7230. Any uri strings with other schemes than http or https are rejected and lead to a thrown stubbles\peer\MalformedUri.

Additionally, instances can be created using HttpUri::fromParts($scheme, $host, $port = null, $path = '/', $queryString = null). (Available since release 4.0.0.)

Rules for specific methods

Changing portions of the HTTP URI

Instances of HttpUri can only be changed regarding their URI parameters. It is not possible to change the host, user, password, port, or fragment of the URI. Additionally it is possible to change the scheme, but this will return a new instance:

The current scheme can be checked with isHttp() and isHttps().

Establish connections to HTTP URIs

Additionally, the class provides possibilities to establish connections to the name HTTP URI:

Establishing a HTTP connection

A HTTP request to the target URI can be done in the following way:

Please note that the call to connect() does not open the connection, but establishes it locally only. Rather, it can be used to add some more headers to the request: user agent, referer, cookies or any other header. Only the last method really opens the connection. Currently, GET, HEAD, POST, PUT and DELETE requests are supported:

For POST and PUT there is one required parameter which should contain the post/put body. For POST alternatively an associative array can be supplied which will be transformed into form post values, which will lead to an automatically added Content-type: application/x-www-form-urlencoded header to the request.

The response can then be read. It provides access to all single details of the HTTP response.

Socket operations

Socket operations can be done using stubbles\peer\Socket. A socket can be created by supplying the host to the constructor, and optionally a port. If no port is specified it will fall back to port 80.

On construction only the socket instance is created. To actually open the connection the connect() method must be called. Optionally a time-out for establishing the connection can be supplied, if none given its 2 seconds. When succesfully established, it returns a stubbles\peer\Stream instance which provides methods to read from and write to the socket.

Other utility classes

stubbles\peer\HeaderList

This class provides possibilities to work with headers, mainly parsing a string which contains headers and maintaining a list of headers.

stubbles\peer\http\AcceptHeader

This class can parse the accept header from HTTP and provides access to check if a certain type is accepted, what it's priority is, and to find the best match if the accept header is compared against a selection of types. It can cope with Accept, Accept-Charset and Accept-Encoding.

stubbles\peer\ParsedUri

Takes a uri string as construction argument and provides access to each part of the uri. In constrast to stubbles\peer\Uri and stubbles\peer\http\HttpUri no checks are done on the url string which means you can construct instances from invalid url strings, which is not possible with both other classes.

stubbles\peer\QueryString

Takes a query string as construction argument and provides access to all of the parameters within the query string to modify and remove them or to add other parameters; and to rebuild a complete query string from this.

stubbles\peer\IpAddress

Available since release 4.0.0

Represents an ip address and possible operations on an ip address.

Integration with stubbles/values

In case the package stubbles/values is present a recognition for stubbles\values\Parse to parse http URIs to instances of stubbles\peer\http\HttpUri will automatically be added.

Also, some checks are added to stubbles\values\Value (available since release 7.1.0):


All versions of peer with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-ctype Version *
ext-filter Version *
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 stubbles/peer contains the following files

Loading the files please wait ....