Download the PHP package astrahttp/swoole-http without Composer

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

AstraHTTP PHP

AstraHTTP PHP is a production-oriented wrapper around a Go-based transport engine. It is designed for high-concurrency HTTP traffic with shared worker management, TLS fingerprint customization, streaming response handling, multipart form encoding, retry support, and WebSocket / SSE protocol hooks.

This document explains the package in detail: installation, architecture, API surface, request options, response methods, streaming, retries, WebSocket / SSE usage, multipart uploads, and practical examples.


1. Requirements

Note: amd64 and x86_64 refer to the same architecture, and arm64 is also known as aarch64.

2. Installation

Using Composer in a project (Recommended)

Installing from source

Autoloading

The library is PSR-4 namespaced and autoloaded through Composer:

The main entry points are:


3. Package overview

The library is structured around four layers:

3.1 Client layer

Astra\SwooleHttp\Client is the public API used by application code. It exposes HTTP methods such as:

Each method returns an AsyncRequestHandle, which can be awaited using ->await().

3.2 Request options layer

Astra\SwooleHttp\Contract\RequestOptions is the configuration object for a request. It contains:

3.3 Runtime layer

The runtime layer manages the external Go worker process and the WebSocket transport between PHP and the worker.

It includes:

This is what gives the library its shared-process behavior and failover behavior.

3.4 Response layer

Responses are represented by Astra\SwooleHttp\Response and may be consumed as:


4. Creating a client

Basic client creation

Configuration options for the client constructor

The client constructor accepts an array with the following keys:

Example

Closing the client

Always close the client when you are finished:

This releases the shared worker reference and helps the runtime shut down cleanly.


5. Main request workflow

The standard flow is:

  1. Create a Client
  2. Build RequestOptions
  3. Call a method such as get() or post()
  4. Receive an AsyncRequestHandle
  5. Call ->await() to get a Response

Example


6. Request methods

The client exposes the following request methods.

6.1 HTTP methods

Each returns an AsyncRequestHandle.

6.2 Protocol-specific methods

These are specialized wrappers that set the protocol field internally.

6.3 Functional-style entry point

You can also use:


7. RequestOptions in detail

Astra\SwooleHttp\Contract\RequestOptions is the central request configuration object.

7.1 Constructor

All properties are optional. Anything not provided remains null or the class default.


8. Request options reference

8.1 headers

Type: array|null

Defines the request headers.

Example:

8.2 cookies

Type: array|object|null

Supported forms:

Associative array form

Array of cookie objects

Object form

8.3 body

Type: mixed

Accepted body forms:

The body is normalized automatically.

String body

JSON body

Any plain array that does not look like multipart is JSON-encoded automatically.

Multipart body

An array becomes multipart when it contains _multipart => true or field entries that look like file descriptors.

Example with file path:

Example with raw in-memory content:

8.4 responseType

Type: json|text|arraybuffer|blob|stream|null

Controls how the response body is presented.

Example:

8.5 TLS fingerprint fields

These fields are passed to the worker for transport fingerprint configuration.

Example:

8.6 Browser / connection fields

Example:

8.7 Retry policy fields

Example:

8.8 Lifecycle hooks

These are local PHP callbacks.

onHeaders

Called when response metadata arrives.

onChunk

Called for response body chunks.

onComplete

Called after a request finishes.

onError

Called when a request fails.


9. Response object in detail

Requests resolve to Astra\SwooleHttp\Response.

9.1 Public properties

9.2 Response methods

text(): string

Returns the raw body as text.

json(): array

Attempts JSON decoding and returns an array.

arrayBuffer(): string

Returns the raw binary content as a string.

blob(): string

Returns the raw binary content as a string.

asStream(): ReadableStream

Returns a readable stream wrapper around the body.

isStreamed(): bool

Returns true if the response was produced with a stream object.

9.3 Examples

Text response

JSON response

Binary response

Stream response


10. Request handle

All request methods return an AsyncRequestHandle.

Methods

Example

This style lets your application structure work around asynchronous request submission.


11. Streaming behavior

Streaming is useful for:

Stream response example

Important note

The stream interface is designed for consumption after the response resolves. For very large payloads, use streaming and process chunks as they arrive.


12. Multipart and file upload scenarios

12.1 Single file upload

12.2 Mixed form fields and files

12.3 Multipart using explicit marker


13. TLS / fingerprint customization

AstraHTTP PHP exposes fields for advanced transport fingerprinting.

Common fields

Example

When to use these

Use fingerprint settings when you need:


14. Retry and failover behavior

The wrapper includes local retry logic for safe methods and configurable retry policies.

Default behavior

If retryable is not set:

Force retry

Disable retry

Practical note

Retry is useful when the worker reconnects or the shared transport is interrupted. The library keeps request-level state separate through request identifiers.


15. Shared worker model

The library uses a shared-worker concept tied to a port.

What this means

Why this matters

This reduces repeated startup costs and makes the wrapper suitable for long-running services and concurrent workloads.

Example

Both clients will share the same worker runtime in the same process space.


16. WebSocket usage

Basic WebSocket request

Notes

The library exposes the protocol field so your worker can treat the request as a WebSocket upgrade or a WS transport flow.

Alias

ws() is an alias for websocket().


17. SSE usage

Basic SSE request

Alias

eventSource() is an alias for sse().

Typical use cases


18. Cookies

Cookies are normalized into the transport-friendly structure expected by the worker.

Associative array example

Array of objects example


19. Common usage patterns

19.1 Simple GET

19.2 POST JSON

19.3 Custom headers

19.4 Custom user agent

19.5 Proxy

19.6 Ignore TLS verification

19.7 Force HTTP/1

19.8 Long timeout


20. Error handling

Wrap requests in try / catch blocks whenever failures are possible.

Example

Typical error sources


21. Practical examples

Example A: read JSON API

Example B: upload a file

Example C: stream a large download

Example D: set TLS fingerprint

Example E: event stream


22. Recommended production practices


23. Minimal full example


24. Summary

AstraHTTP PHP is best used when you need:

The package is designed to feel like a modern async client while still fitting naturally into PHP 8.2+ applications.


All versions of swoole-http with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
amphp/amp Version ^3.0
amphp/byte-stream Version ^2.1
amphp/websocket-client Version ^2.0
revolt/event-loop Version ^1.0
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 astrahttp/swoole-http contains the following files

Loading the files please wait ...