PHPackages                             fyre/server - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. fyre/server

ActiveLibrary[HTTP &amp; Networking](/categories/http)

fyre/server
===========

A HTTP server request/response library.

v5.0(7mo ago)1398↓83.3%9MITPHP

Since Dec 25Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/elusivecodes/FyreServer)[ Packagist](https://packagist.org/packages/fyre/server)[ RSS](/packages/fyre-server/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (14)Versions (46)Used By (9)

FyreServer
==========

[](#fyreserver)

**FyreServer** is a free, open-source immutable HTTP server request/response library for *PHP*.

Table Of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Server Requests](#server-requests)
- [Client Responses](#client-responses)
- [Download Responses](#download-responses)
- [Redirect Responses](#redirect-responses)
- [Uploaded Files](#uploaded-files)

Installation
------------

[](#installation)

**Using Composer**

```
composer require fyre/server

```

Server Requests
---------------

[](#server-requests)

This class extends the [*Request*](https://github.com/elusivecodes/FyreRequest) class.

```
use Fyre\Server\ServerRequest;
```

- `$config` is a [*Config*](https://github.com/elusivecodes/FyreConfig).
- `$typeParser` is a [*TypeParser*](https://github.com/elusivecodes/FyreTypeParser).
- `$options` is an array containing configuration options.
    - `method` is a string representing the request method, and will default to the server request method.
    - `body` is a string or *StreamInterface* representing the message body, and will default to `php://input`.
    - `headers` is an array containing headers to set, and will default to the server headers.
    - `protocolVersion` is a string representing the protocol version, and will default to "*1.1*".

```
$request = new ServerRequest($config, $typeParser, $options);
```

Default configuration options will be resolved from the "*App*" key in the [*Config*](https://github.com/elusivecodes/FyreConfig).

- `$options` is an array containing configuration options.
    - `baseUri` is a string representing the base URI to use, and will default to "".
    - `defaultLocale` is a string representing the default locale, and will default to the system default.
    - `supportedLocales` is an array containing the supported locales, and will default to `[]`.

```
$container->use(Config::class)->set('App', $options);
```

**Autoloading**

It is recommended to bind the *ServerRequest* to the [*Container*](https://github.com/elusivecodes/FyreContainer) as a singleton.

```
$container->singleton(ServerRequest::class);
```

Any dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).

```
$request = $container->use(ServerRequest::class);
```

### Server Request Methods

[](#server-request-methods)

**Get Attribute**

Get an attribute from the request.

- `$key` is a string representing the attribute key.

```
$attribute = $request->getAttribute($key);
```

**Get Attributes**

Get all attributes from the request.

```
$attributes = $request->getAttributes();
```

**Get Cookie**

Get a value from the `$_COOKIE` array.

- `$key` is a string representing the array key using "dot" notation.
- `$as` is a string representing the value type, and will default to *null*.

```
$value = $request->getCookie($key, $as);
```

**Get Cookie Params**

Get the `$_COOKIE` array.

```
$values = $request->getCookieParams();
```

**Get Data**

Get a value from the `$_POST` array or parsed body data.

- `$key` is a string representing the array key using "dot" notation.
- `$as` is a string representing the value type, and will default to *null*.

```
$value = $request->getData($key, $as);
```

**Get Default Locale**

Get the default locale.

```
$defaultLocale = $request->getDefaultLocale();
```

**Get Environment**

Get a value from the `$_ENV` array.

- `$key` is a string representing the array key.
- `$as` is a string representing the value type, and will default to *null*.

```
$value = $request->getEnv($key, $as);
```

**Get Locale**

Get the current locale.

```
$locale = $request->getLocale();
```

**Get Param**

Get a route parameter.

- `$key` is a string representing the parameter key.

```
$param = $request->getParam();
```

**Get Parsed Body**

Get the parsed body data.

```
$values = $request->getParsedBody();
```

**Get Query**

Get a value from the `$_GET` array.

- `$key` is a string representing the array key using "dot" notation.
- `$as` is a string representing the value type, and will default to *null*.

```
$value = $request->getQuery($key, $as);
```

**Get Query Params**

Get the `$_GET` array.

```
$values = $request->getQueryParams();
```

**Get Server**

Get a value from the `$_SERVER` array.

- `$key` is a string representing the array key.
- `$as` is a string representing the value type, and will default to *null*.

```
$value = $request->getServer($key, $as);
```

**Get Server Params**

Get the `$_SERVER` array.

```
$values = $request->getServerParams();
```

**Get Uploaded File**

Get an *UploadedFile* or array of files from the `$_FILE` array.

- `$key` is a string representing the array key using "dot" notation.

```
$file = $request->getUploadedFile($key);
```

**Get Uploaded Files**

Get the uploaded files from the $\_FILE array.

```
$files = $request->getUploadedFiles();
```

**Get User Agent**

Get the user agent.

```
$userAgent = $request->getUserAgent();
```

This method will return a [*UserAgent*](https://github.com/elusivecodes/FyreUserAgent).

**Is AJAX**

Determine whether the request was made using AJAX.

```
$isAjax = $request->isAjax();
```

**Is CLI**

Determine whether the request was made from the CLI.

```
$isCli = $request->isCli();
```

**Is Secure**

Determine whether the request is using HTTPS.

```
$isSecure = $request->isSecure();
```

**Negotiate**

Negotiate a value from HTTP headers.

- `$type` is a string representing the type of negotiation to perform, and must be one of either "*content*", "*encoding*" or "*language*".
- `$supported` is an array containing the supported values.
- `$strict` is a boolean indicating whether to not use a default fallback, and will default to *false*.

```
$value = $request->negotiate($type, $supported, $strict);
```

**With Attribute**

Clone the *ServerRequest* with a new attribute.

- `$key` is a string representing the attribute key.
- `$value` is the attribute value.

```
$newRequest = $request->withAttribute($key, $value);
```

**With Cookie Params**

Clone the *ServerRequest* with new cookie parameters.

- `$data` is an array containing the new cookie parameters.

```
$newRequest = $request->withCookieParams($data);
```

**With Locale**

Clone the *ServerRequest* with a new locale.

- `$locale` is a string representing the locale.

```
$newRequest = $request->withLocale($locale);
```

The locale must be present in the `supportedLocales` property of the *ServerRequest* `$options` parameter.

**Without Attribute**

Clone the *ServerRequest* without an attribute.

- `$key` is a string representing the attribute key.

```
$newRequest = $request->withoutAttribute($key);
```

**With Param**

Clone the *ServerRequest* with new a new parameter.

- `$key` is a string representing the parameter key.
- `$value` is the parameter value.

```
$newRequest = $request->withParam($key, $value);
```

**With Parsed Body**

Clone the *ServerRequest* with new a new parsed body.

- `$data` is an array containing the new parsed body.

```
$newRequest = $request->withParsedData($data);
```

**With Query Params**

Clone the *ServerRequest* with new query parameters.

- `$data` is an array containing the new query parameters.

```
$newRequest = $request->withQueryParams($data);
```

**With Server Params**

Clone the *ServerRequest* with new server parameters.

- `$data` is an array containing the new server parameters.

```
$newRequest = $request->withServerParams($data);
```

**With Uploaded Files**

Clone the *ServerRequest* with new uploaded files.

- `$data` is an array containing the new [uploaded files](#uploaded-files).

```
$newRequest = $request->withUploadedFiles($data);
```

Client Responses
----------------

[](#client-responses)

This class extends the [*Response*](https://github.com/elusivecodes/FyreResponse) class.

```
use Fyre\Server\ClientResponse;
```

- `$options` is an array containing configuration options.
    - `body` is a string or *StreamInterface* representing the message body, and will default to "".
    - `headers` is an array containing additional headers to set.
    - `protocolVersion` is a string representing the protocol version, and will default to "*1.1*".
    - `statusCode` is a number representing the status code, and will default to *200*.

```
$response = new ClientResponse($options);
```

**Get Cookie**

- `$name` is a string representing the cookie name.

```
$cookie = $response->getCookie($name);
```

This method will return a [*Cookie*](https://github.com/elusivecodes/FyreCookie).

**Has Cookie**

Determine whether a cookie has been set.

- `$name` is a string representing the cookie name.

```
$hasCookie = $response->hasCookie($name);
```

**Send**

Send the response to the client.

```
$response->send();
```

**With Content Type**

Clone the *ClientResponse* with a new content type.

- `$mimeType` is a string representing the MIME type.
- `$charset` is a string representing the character set, and will default to "*UTF-8*".

```
$newResponse = $response->withContentType($mimeType, $charset);
```

**With Cookie**

Clone the *ClientResponse* with a new cookie.

- `$name` is a string representing the cookie name.
- `$value` is a string representing the cookie value.
- `$options` is an array containing cookie options.
    - `expires` is a number representing the cookie lifetime, and will default to 0.
    - `domain` is a string representing the cookie domain, and will default to "".
    - `path` is a string representing the cookie path, and will default to "*/*".
    - `secure` is a boolean indicating whether to set a secure cookie, and will default to *false*.
    - `httpOnly` is a boolean indicating whether to the cookie should be HTTP only, and will default to *false*.
    - `sameSite` is a string representing the cookie same site, and will default to "*Lax*".

```
$newResponse = $response->withCookie($name, $value, $options);
```

**With Date**

Clone the *ClientResponse* with a new date header.

- `$date` is a string, number or *DateTime* object representing the date.

```
$newResponse = $response->withDate($date);
```

**With Disabled Cache**

Clone the *ClientResponse* with disabled cache heades

```
$newResponse = $response->withDisabledCache();
```

**With Expired Cookie**

Clone the *ClientResponse* with a new expired cookie.

- `$name` is a string representing the cookie name.
- `$options` is an array containing cookie options.
    - `domain` is a string representing the cookie domain, and will default to "".
    - `path` is a string representing the cookie path, and will default to "*/*".
    - `secure` is a boolean indicating whether to set a secure cookie, and will default to *false*.
    - `httpOnly` is a boolean indicating whether to the cookie should be HTTP only, and will default to *false*.
    - `sameSite` is a string representing the cookie same site, and will default to "*Lax*".

```
$newResponse = $response->withExpiredCookie($name, $options);
```

**With JSON**

Clone the *ClientResponse* with a new JSON body.

- `$data` is the data to send.

```
$newResponse = $response->withJson($data);
```

**With Last Modified**

Clone the *ClientResponse* with a new last modified date header.

- `$date` is a string, number or *DateTime* object representing the date.

```
$newResponse = $response->withLastModified($date);
```

**With XML**

Clone the *ClientResponse* with a new XML body.

- `$data` is a *SimpleXMLElement* containing the data to send.

```
$newResponse = $response->withXml($data);
```

Download Responses
------------------

[](#download-responses)

This class extends the [*ClientResponse*](#client-responses) class.

```
use Fyre\Server\DownloadResponse;
```

- `$path` is a string representing the file path.
- `$options` is an array containing configuration options.
    - `filename` is a string representing the download filename, and will default to the file name.
    - `mimeType` is a string representing the MIME type, and will default to the file MIME type.
    - `headers` is an array containing additional headers to set.
    - `protocolVersion` is a string representing the protocol version, and will default to "*1.1*".
    - `statusCode` is a number representing the status code, and will default to *200*.

```
$response = new DownloadResponse($path, $options);
```

**Create From String**

- `$data` is a string representing the file data.
- `$options` is an array containing configuration options.
    - `filename` is a string representing the download filename, and will default to the file name.
    - `mimeType` is a string representing the MIME type, and will default to the file MIME type.

```
$response = DownloadResponse::createFromString($data, $options);
```

Redirect Responses
------------------

[](#redirect-responses)

This class extends the [*ClientResponse*](#client-responses) class.

```
use Fyre\Server\RedirectResponse;
```

- `$uri` is a [*Uri*](https://github.com/elusivecodes/FyreURI) or string representing the URI to redirect to.
- `$code` is a number representing the header status code, and will default to *302*.
- `$options` is an array containing configuration options.

```
$response = new RedirectResponse($uri, $code $options);
```

Uploaded Files
--------------

[](#uploaded-files)

**Get Client Filename**

Get the client filename.

```
$filename = $uploadedFile->getClientFilename();
```

**Get Client Media Type**

Get the client media type.

```
$mediaType = $uploadedFile->getClientMediaType();
```

**Get Error**

Get the uploaded error code.

```
$error = $uploadedFile->getError();
```

**Get Size**

Get the uploaded file size.

```
$size = $uploadedFile->getSize();
```

**Get Stream**

Get a [*Stream*](https://github.com/elusivecodes/FyreStream) representing the uploaded file.

```
$stream = $uploadedFile->getStream();
```

**Move To**

Move the uploaded file.

- `$targetPath` is string representing the target path.

```
$uploadedFile->moveTo($targetPath);
```

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance63

Regular maintenance activity

Popularity14

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~32 days

Recently: every ~53 days

Total

45

Last Release

224d ago

Major Versions

v1.1.1 → v2.02023-08-05

v2.0.5 → v3.02024-06-02

v3.3.5 → v4.02024-11-17

v4.2.6 → v5.02025-11-11

### Community

Maintainers

![](https://www.gravatar.com/avatar/fad81fd5941e3a637c8a5749d05ae3ed9314d5e2fee57f59c3d9ec3b41259c6b?d=identicon)[elusivecodes](/maintainers/elusivecodes)

---

Top Contributors

[![elusivecodes](https://avatars.githubusercontent.com/u/18050480?v=4)](https://github.com/elusivecodes "elusivecodes (30 commits)")

---

Tags

phprequestresponseserverupload

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/fyre-server/health.svg)

```
[![Health](https://phpackages.com/badges/fyre-server/health.svg)](https://phpackages.com/packages/fyre-server)
```

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

7.9k1.1B3.7k](/packages/guzzlehttp-psr7)[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.2k532.1M2.5k](/packages/aws-aws-sdk-php)[symfony/psr-http-message-bridge

PSR HTTP message bridge

1.3k312.3M929](/packages/symfony-psr-http-message-bridge)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k496.1k33](/packages/neuron-core-neuron-ai)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35729.6k2](/packages/telnyx-telnyx-php)[laudis/neo4j-php-client

Neo4j-PHP-Client is the most advanced PHP Client for Neo4j

185671.3k41](/packages/laudis-neo4j-php-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
