PHPackages                             sametsahindogan/response-object-creator - 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. [API Development](/categories/api)
4. /
5. sametsahindogan/response-object-creator

ActiveLibrary[API Development](/categories/api)

sametsahindogan/response-object-creator
=======================================

This package provide to standardized response objects for your API.

v1.0.2(6y ago)77.3k↓33.3%1MITPHPPHP ^7.0

Since Jan 21Pushed 6y ago1 watchersCompare

[ Source](https://github.com/sametsahindogan/response-object-creator)[ Packagist](https://packagist.org/packages/sametsahindogan/response-object-creator)[ RSS](/packages/sametsahindogan-response-object-creator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (1)

response-object-creator
=======================

[](#response-object-creator)

[![GitHub license](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://raw.githubusercontent.com/sametsahindogan/response-object-creator/master/LICENSE)

> This package provides to standardized response objects for your API.

[![](https://camo.githubusercontent.com/35d5ec037855822c56a6f990699b4a0b3325006e92572474419448cb1534703a/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f7468756d622f362f36612f4e756c6c7365742e7376672f3132303070782d4e756c6c7365742e7376672e706e67)](https://camo.githubusercontent.com/35d5ec037855822c56a6f990699b4a0b3325006e92572474419448cb1534703a/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f7468756d622f362f36612f4e756c6c7365742e7376672f3132303070782d4e756c6c7365742e7376672e706e67)

> One of the important things in an API is that it has a standard response type. This package provides a standard response structure for your API.

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

[](#installation)

```
composer require sametsahindogan/response-object-creator
```

Usage
-----

[](#usage)

**If you want to return a "success" result;**

```
// Your array that you want to return as an object.
 $data = [
        'id' => 1,
        'name' => 'John',
        'surname' => 'Doe'
    ];

// If you use pure PHP;
 return json_encode( new SuccessResult($data) );

// If you use Laravel Framework;
 return response()->json( new SuccessResult($data) );

// If you use Symfony Framework;
 return new JsonResponse( new SuccessResult($data) );
```

Output;

```
{
      "success": true,
      "data": {
          "id": 1,
          "name": "John",
          "surname": "Doe"
      }
}
```

**If you want to return an "error" result;**

```
// You must create an Error Builder object.
 $errorBuilder = new ErrorBuilder();

// If you use pure PHP;
  return json_encode(new ErrorResult(
             $errorBuilder->title('Error')
                 ->message('Something wrong happened.')
                 ->code(1)
                 ->extra(['You can add some extra messages or etc.'])
         )
     );

// If you use Laravel Framework;
 return response()->json(new ErrorResult(
             $errorBuilder->title('Error')
                 ->message('Something wrong happened.')
                 ->code(1)
                 ->extra(['You can add some extra messages or etc.'])
         )
     );

// If you use Symfony Framework;
 return new JsonResponse(new ErrorResult(
             $errorBuilder->title('Error')
                 ->message('Something wrong happened.')
                 ->code(1)
                 ->extra(['You can add some extra messages or etc.'])
         )
     );
```

Output;

```
{
      "success": false,
      "data": {
          "message": "User does not have the right roles or permissions.",
          "title": "Operation Failed",
          "code": 1,
          "extra": [
               "You can add some extra messages or etc."
          ]
      }
}
```

License
-------

[](#license)

MIT © [Samet Sahindogan](https://github.com/sametsahindogan/laravel-jwtredis/blob/master/LICENSE)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

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

Total

2

Last Release

2309d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/473ceed3f0cea57f7ea1e773f16ecaf17abdc40278285db38fc8ebdbd0599419?d=identicon)[sametsahindogan](/maintainers/sametsahindogan)

---

Top Contributors

[![sametsahindogan](https://avatars.githubusercontent.com/u/36247856?v=4)](https://github.com/sametsahindogan "sametsahindogan (2 commits)")

---

Tags

jsonrest-api

### Embed Badge

![Health badge](/badges/sametsahindogan-response-object-creator/health.svg)

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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