PHPackages                             antoniog85/mediatype - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. antoniog85/mediatype

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

antoniog85/mediatype
====================

A PHP implementation of some common media types. Uses Symfony HTTP-foundation

013PHP

Since Mar 29Pushed 10y ago1 watchersCompare

[ Source](https://github.com/antoniog85/mediatype)[ Packagist](https://packagist.org/packages/antoniog85/mediatype)[ RSS](/packages/antoniog85-mediatype/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Media types
===========

[](#media-types)

Collection+JSON
---------------

[](#collectionjson)

Integration
-----------

[](#integration)

### Silex

[](#silex)

```
$app->after(function (Request $request, Response $response) use ($app) {
    $collectionJson = new \Antoniog85\MediaType\CollectionJson();
    $collectionJson->setVersion(getenv('API_VERSION'));
    $collectionJson->setHref($request->getUri());
    $collectionJson->setError($response);
    $collectionJson->setItems($response);

    return $app->json(
        $collectionJson->render(),
        $response->getStatusCode(),
        [
            'Access-Control-Allow-Origin' => '*',
            'Access-Control-Allow-Methods' => 'GET,POST,PUT,DELETE,OPTIONS',
            'Content-Type' => 'application/vnd.collection+json',
        ]
    );
});

```

### Lumen

[](#lumen)

```
class AfterMiddleware
{
    public function handle($request, Closure $next): Response
    {
        /** @var Response $response */
        $response = $next($request);
        $response->headers->add([
            'Access-Control-Allow-Origin' => '*',
            'Access-Control-Allow-Methods' => 'GET,POST,PUT,DELETE,OPTIONS',
            'Content-Type' => 'application/vnd.collection+json',
        ]);
        $collectionJson = new \Antoniog85\MediaType\CollectionJson();
        $collectionJson->setVersion(getenv('API_VERSION'));
        $collectionJson->setHref($request->getUri());
        $collectionJson->setError($response);
        $collectionJson->setItems($response);
        $response->setContent($collectionJson->render());
        return $response;
    }
}

```

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/328347?v=4)[Antonio Giuliana](/maintainers/antoniog85)[@antoniog85](https://github.com/antoniog85)

### Embed Badge

![Health badge](/badges/antoniog85-mediatype/health.svg)

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

###  Alternatives

[dbrekelmans/bdi

PHAR distribution of dbrekelmans/browser-driver-installer.

656.3M162](/packages/dbrekelmans-bdi)[kubotak-is/php-del

Tool to remove code based on specific comments.

1648.6k](/packages/kubotak-is-php-del)

PHPackages © 2026

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