PHPackages                             fivelab/resource - 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. fivelab/resource

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

fivelab/resource
================

Simple resource and serialization system for application

v2.1.1(2y ago)120.8k1MITPHPPHP ~8.0

Since Sep 4Pushed 2y ago1 watchersCompare

[ Source](https://github.com/FiveLab/Resource)[ Packagist](https://packagist.org/packages/fivelab/resource)[ RSS](/packages/fivelab-resource/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (7)Versions (7)Used By (1)

Russia has become a terrorist state.
------------------------------------

[](#russia-has-become-a-terrorist-state)

  #StandWithUkraine

Resource System
===============

[](#resource-system)

[![Build Status](https://github.com/FiveLab/Resource/workflows/Testing/badge.svg?branch=master)](https://github.com/FiveLab/Resource/actions)

Add functionality for work with resources in you application and serialize this resources to any formats.

Support formats:

- WebAPI - simple JSON/XML structure.
- [HATEOAS](https://en.wikipedia.org/wiki/HATEOAS)
- [VndError](https://github.com/blongden/vnd.error)

Requirements
------------

[](#requirements)

- PHP 7.4 or higher

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

[](#installation)

Add Resource package in your composer.json:

```
{
    "require": {
        "fivelab/resource": "~2.0"
    }
}
```

Now tell composer to download the library by running the command:

```
php composer.phar update fivelab/resource
```

Problem
-------

[](#problem)

More web applications use API (Application Programming Interface) with difference result structures. It's difficult for developers and clients (who use this API) because each developer can return any data (JSON or XML). And in more cases, applications does not support media types and return JSON data with any `Content-Type` header.

And in most cases, developers use real entities from database for map to JSON (as an example `symfony/serializer`). This work funny, because one entity in backend application can representation to many resources for clients. As an example: we have `User` entity with more data. If user authorized, we must return all data, but if user not logged, we must return less data (`id` and `avatar` as an example). Yes, more people speak what we have a group system, but what will happen if I say that we should have more than 100 groups? Yes, in large application it's real case.

In this library we try to resolve all issue related with API.

> Note: we don't speak - `API`, we must speak - `Resource`, because all operations (create, edit, delete, etc...) are performed on one resource (`Blog` as an example).

Solution
--------

[](#solution)

1. Full isolate between model in database and resource for representation. Model from database convert to resource via `Assembler`. `Blog -> Assembler -> BlogResource`. By this we can create any resources for one model in database. (For `Blog` as example: `BlogResoure`, `PremiumBlogResoure`, `HotBlogResource`, etc...). We don't use group system for separate, we have a separate assembler for each resource.
2. We full support [media type](https://en.wikipedia.org/wiki/Media_type) (`Content-Type/Accept`). If client accept `json`, we return `json`, if client accept `xml`, we return `xml`(but previously we must configure it ;) ). And - one resource, many formats ;)

> Note: in our library we use `symfony/serializer` with custom normalizers and additional functionality. As result, all you custom normalizers/denormaizers will be normal work with our library.

License
-------

[](#license)

This library is under the MIT license. See the complete license in library

```
LICENSE

```

Development
-----------

[](#development)

For easy development you can use our `Dockerfile`:

```
docker build -t fivelab-resource .
docker run -it -v $(pwd):/code fivelab-resource bash
```

After run docker container, please install vendors:

```
composer install
```

Reporting an issue or a feature request
---------------------------------------

[](#reporting-an-issue-or-a-feature-request)

Issues and feature requests are tracked in the [Github issue tracker](https://github.com/FiveLab/Resource/issues).

Contributors:
-------------

[](#contributors)

Thanks to [everyone participating](https://github.com/FiveLab/Resource/graphs/contributors) in the development of this Resource library!

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity72

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

Recently: every ~330 days

Total

6

Last Release

1048d ago

Major Versions

v1.1.0 → v2.0.02021-05-27

PHP version history (3 changes)v1.0.0PHP &gt;=7.1

v2.0.0PHP ~7.4 || ~8.0

v2.1.0PHP ~8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/626ec10367b16fd0c7f8279eec25caa64084d5bd9a01789e0645279988e9a185?d=identicon)[ZhukV](/maintainers/ZhukV)

---

Top Contributors

[![ZhukV](https://avatars.githubusercontent.com/u/2256109?v=4)](https://github.com/ZhukV "ZhukV (50 commits)")

---

Tags

apirestserializerresourceHATEOASweb-api

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/fivelab-resource/health.svg)

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

###  Alternatives

[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k48.1M236](/packages/api-platform-core)[api-platform/serializer

API Platform core Serializer

223.4M31](/packages/api-platform-serializer)[api-platform/symfony

Symfony API Platform integration

323.2M67](/packages/api-platform-symfony)[api-platform/openapi

Models to build and serialize an OpenAPI specification.

353.3M48](/packages/api-platform-openapi)[infobip/infobip-api-php-client

PHP library for consuming Infobip's API

921.8M10](/packages/infobip-infobip-api-php-client)[api-platform/state

API Platform state interfaces

223.4M57](/packages/api-platform-state)

PHPackages © 2026

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