PHPackages                             anax/response - 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. [Framework](/categories/framework)
4. /
5. anax/response

ActiveLibrary[Framework](/categories/framework)

anax/response
=============

Anax Response module, to create a HTTP response.

v2.0.2(5y ago)019.7k↓90%2[1 PRs](https://github.com/canax/response/pulls)20MITPHPPHP ^7.2CI failing

Since Mar 7Pushed 5y ago1 watchersCompare

[ Source](https://github.com/canax/response)[ Packagist](https://packagist.org/packages/anax/response)[ Docs](https://dbwebb.se/anax)[ RSS](/packages/anax-response/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (4)Versions (23)Used By (20)

Anax Response
=============

[](#anax-response)

[![Latest Stable Version](https://camo.githubusercontent.com/c8c125b67a8bdb7365b1ce51aa2613130ccb4d706e56c95e84791ba37a44ca8b/68747470733a2f2f706f7365722e707567782e6f72672f616e61782f726573706f6e73652f762f737461626c65)](https://packagist.org/packages/anax/response)[![Join the chat at https://gitter.im/mosbth/anax](https://camo.githubusercontent.com/abe08b740a4156153736f791393ec4da6619c4be73212e75769f52edacc0e2b5/68747470733a2f2f6261646765732e6769747465722e696d2f4a6f696e253230436861742e737667)](https://gitter.im/canax?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

[![Build Status](https://camo.githubusercontent.com/b1038afcc5fdce7cf93a0257c4a4b4265d9c1ce61cc83029daed25ffb13d63bb/68747470733a2f2f7472617669732d63692e6f72672f63616e61782f726573706f6e73652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/canax/response)[![CircleCI](https://camo.githubusercontent.com/8e595c1dfd6dd5129b30ab538c2dc8b8962cf4597801f74baf27d110c1674f26/68747470733a2f2f636972636c6563692e636f6d2f67682f63616e61782f726573706f6e73652e7376673f7374796c653d737667)](https://circleci.com/gh/canax/response)

[![Build Status](https://camo.githubusercontent.com/a6e7255c32e0ed30066f59b85af4856d81b1bfe371ee4fc5c4f2d26c0ff20c83/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f63616e61782f726573706f6e73652f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/canax/response/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/e6d458446b90fbc95020932346d083e1aa72bc5465579f551b113e11e714f4a9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f63616e61782f726573706f6e73652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/canax/response/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/0addcfc19ffae118520ce5d379b06fc44a4168bc9ab81d4680908c9e0d9d1fef/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f63616e61782f726573706f6e73652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/canax/response/?branch=master)

[![Maintainability](https://camo.githubusercontent.com/17f5a4a10b9a4bb7c5e8cd08d6ca558a77726b7d3c954225bc07dff5e006a364/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f36643130633135643133323330623461663036662f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/canax/response/maintainability)[![Codacy Badge](https://camo.githubusercontent.com/98c9a63de319e0e95b071d6c2dbd92467ae32dbdf4d8e7fc323f0b0bb4bc00d1/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3761643162353337633035363461643661316534336661393365353934656136)](https://www.codacy.com/app/mosbth/response?utm_source=github.com&utm_medium=referral&utm_content=canax/response&utm_campaign=Badge_Grade)

Anax Response module to send HTTP responses.

The module is used to send a HTTP response from the Anax framework, including status code, headers, and body.

Table of content
----------------

[](#table-of-content)

- [Class, interface, trait](#class-interface-trait)
- [Exceptions](#exceptions)
- [Configuration file](#configuration-file)
- [DI service](#di-service)
- [General usage within the Anax framework](#general-usage-within-the-Anax-framework)
- [Access as framework service](#access-as-framework-service)
- [Create, init and use an object](#create-init-and-use-an-object)

Class, interface, trait
-----------------------

[](#class-interface-trait)

The following classes, interfaces and traits exists.

Class, interface, traitDescription`Anax\Response\Response`Wrapper class for response details and related.`Anax\Response\ResponseUtility`Extends the Request class to be injectable with `$id` to enable easy to use redirect methods.Exceptions
----------

[](#exceptions)

Module specific exceptions are thrown through `Anax\Response\Exception`.

Configuration file
------------------

[](#configuration-file)

There is no configuration file for this module.

DI service
----------

[](#di-service)

The module is created as a framework service within `$di`. You can see the details in the configuration file [`config/di/response.php`](config/di/seponse.php).

It can look like this.

```
/**
 * Configuration file for DI container.
 */
return [
    // Services to add to the container.
    "services" => [
        "response" => [
            "shared" => true,
            //"callback" => "\Anax\Response\Response",
            "callback" => function () {
                $obj = new \Anax\Response\ResponseUtility();
                $obj->setDI($this);
                return $obj;
            }
        ],
    ],
];
```

1. The object is created as a shared resource.
2. DI is injected into the module, when using ResponseUtility.

The service is lazy loaded and not created until it is used.

General usage within the Anax framework
---------------------------------------

[](#general-usage-within-the-anax-framework)

The response service is a mandatory service within the Anax framework and it is the first service used when handling a request to the framework.

Here is the general flow for receiving a request, mapping it to a route and returning a response. This is found in the frontcontroller `htdocs/index.php` of an Anax installation.

```
// Leave to router to match incoming request to routes
$response = $di->get("router")->handle(
    $di->get("request")->getRoute(),
    $di->get("request")->getMethod()
);
// Send the HTTP response with headers and body
$di->get("response")->send($response);
```

The request is used to get the request method and the route path, these are used by the router service to find a callback for the route. Each callback can then return a response which is sent through the response service.

Access as framework service
---------------------------

[](#access-as-framework-service)

You can access the module as a framework service.

```
# $app style
$app->response->redirectSelf();

# $di style, two alternatives
$di->get("response")->redirectSelf();

$response = $di->get("response");
$response->redirectSelf();
```

Create, init and use an object
------------------------------

[](#create-init-and-use-an-object)

This is how the object can be created. This is usually done within the framework as a sevice in `$di`.

```
# Create an object
response = new \Anax\Response\Response();

# Send a response
response->send("Some response");
response->sendJson(["key" => "Some value"]);
response->redirect($absoluteUrl);
```

The added benefit of using ResponseUtility is that this class is injected with DI and makes it easier to use the redirect methods for urls within the framework.

```
# Create an object
response = new \Anax\Response\ResponseUtility();

# Do a redirect
response->redirect("game/init");
response->redirectSelf();
```

License
-------

[](#license)

This software carries a MIT license. See [LICENSE.txt](LICENSE.txt) for details.

```
 .
..:  Copyright (c) 2013 - 2019 Mikael Roos, mos@dbwebb.se

```

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity68

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 ~63 days

Recently: every ~194 days

Total

22

Last Release

2065d ago

Major Versions

v1.0.8 → v2.0.0-alpha.12018-08-01

PHP version history (2 changes)v1.0.0PHP &gt;=5.6

v2.0.0-alpha.1PHP ^7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/4cac244120f54c02a4fb3186b91323f3f0805dd9daefd0babeb4a82a19232faf?d=identicon)[mikael\_roos](/maintainers/mikael_roos)

---

Top Contributors

[![mosbth](https://avatars.githubusercontent.com/u/169550?v=4)](https://github.com/mosbth "mosbth (41 commits)")

---

Tags

frameworkmicromvcboilerplateeducation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/anax-response/health.svg)

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

PHPackages © 2026

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