PHPackages                             signifly/laravel-api-responder - 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. signifly/laravel-api-responder

AbandonedArchivedLibrary[API Development](/categories/api)

signifly/laravel-api-responder
==============================

API Responses for your Laravel API.

v2.0.0(2y ago)75.2k2[1 PRs](https://github.com/signifly/laravel-api-responder/pulls)MITPHPPHP ^7.2.5 || ^8.0

Since May 23Pushed 2y ago1 watchersCompare

[ Source](https://github.com/signifly/laravel-api-responder)[ Packagist](https://packagist.org/packages/signifly/laravel-api-responder)[ Docs](https://github.com/signifly/laravel-api-responder)[ RSS](/packages/signifly-laravel-api-responder/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (6)Versions (16)Used By (0)

API Responses for your Laravel API
==================================

[](#api-responses-for-your-laravel-api)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8903da8de6d3aa9a869312ef5fcafacfad3bc0c6c73547db069f4bbc6c5942ef/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7369676e69666c792f6c61726176656c2d6170692d726573706f6e6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/signifly/laravel-api-responder)[![Build Status](https://camo.githubusercontent.com/8bcb5ced55f7e4c705c19729a43179cb4fd7531d6f34592d6b28519fc70aef97/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7369676e69666c792f6c61726176656c2d6170692d726573706f6e6465722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/signifly/laravel-api-responder)[![StyleCI](https://camo.githubusercontent.com/13bd4ab0dbb9472eb5b99011e338bddb45f7b1d33cb3fd50e06929627ce1bddd/68747470733a2f2f7374796c6563692e696f2f7265706f732f3138383231313037392f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/188211079)[![Quality Score](https://camo.githubusercontent.com/15587f0c44807249ba4c3fff7ebd35c18417b137092f91377ceb510ed875b6cd/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7369676e69666c792f6c61726176656c2d6170692d726573706f6e6465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/signifly/laravel-api-responder)[![Total Downloads](https://camo.githubusercontent.com/b802ef2d11eb29d5cb6310dc72f5796b7a1bc4e66888339be7e1e96736098301/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7369676e69666c792f6c61726176656c2d6170692d726573706f6e6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/signifly/laravel-api-responder)

The `signifly/laravel-api-responder` package allows you to easily return API responses in your Laravel app.

Below is a small example of how to use it:

```
use Signifly\Responder\Concerns\Respondable;

class ProductController extends Controller
{
    use Respondable;

    public function index()
    {
        $paginator = Product::paginate();

        return $this->respond($paginator);
    }

    public function store(Request $request)
    {
        $product = Product::create($request->all());

        return $this->respond($product->fresh())
            ->setStatusCode(201); // responds with a 201 status code
    }

    public function show(Product $product)
    {
        return $this->respond($product);
    }

    public function destroy(Product $product)
    {
        $product->delete();

        return $this->respond($product); // return an empty 204 json response
    }
}
```

It will automatically resolve resources for the provided data if they exist.

Documentation
-------------

[](#documentation)

To get started follow the installation instructions below.

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

[](#installation)

You can install the package via composer:

```
composer require signifly/laravel-api-responder
```

The package will automatically register itself.

You can optionally publish the config file with:

```
php artisan vendor:publish --tag="responder-config"
```

This is the contents of the published config file:

```
return [

    /*
     * The namespace to use when resolving resources.
     */
    'namespace' => 'App\\Http\\Resources',

    /*
     * Force the usage of resources.
     *
     * It will throw a ResourceNotFoundException
     * if it does not resolve a resource.
     */
    'force_resources' => false,

    /*
     * Indicates if the resources uses a naming convention with a type suffix.
     *
     * If it is set to true it will try to resolve `UserResource`.
     */
    'use_type_suffix' => false,

];
```

Usage
-----

[](#usage)

The responder can be used in several ways.

### Using the Facade

[](#using-the-facade)

```
use Signifly\Responder\Facades\Responder;

class ProductController
{
    public function show(Product $product)
    {
        return Responder::respond($product);
    }
}
```

### Using the Trait

[](#using-the-trait)

```
use Signifly\Responder\Concerns\Respondable;

class ProductController
{
    use Respondable;

    public function show(Product $product)
    {
        return $this->respond($product);
    }
}
```

### Using the Service Container

[](#using-the-service-container)

```
use Signifly\Responder\Contracts\Responder;

class ProductController
{
    public function show(Product $product, Responder $responder)
    {
        return $responder->respond($product);
    }
}
```

### Custom response codes

[](#custom-response-codes)

You can set the status code of the response by using the `setStatusCode` method on the response from the responder.

```
return Responder::respond($data)
    ->setStatusCode(201);
```

### Specific resource classes

[](#specific-resource-classes)

If you would like to specify a resource class it can be passed as the second parameter to the respond method:

```
return Responder::respond($data, UserResource::class);
```

### Forcing the usage of API resources

[](#forcing-the-usage-of-api-resources)

If you want to force the usage of API resources, you have to set the `force_resources` option to `true` in the `config/responder.php` file.

When set to true it will throw a `ResourceNotFoundException` if a resource for the associated model could not be found.

### Using type suffixes

[](#using-type-suffixes)

If you are using type suffixes as naming convention, when creating new resources, then you should set the `use_type_suffix` option to `true` in the `config/responder.php` file.

When set to true it expects your resources to be named like `UserResource` instead of just `User`.

Testing
-------

[](#testing)

```
composer test
```

Security
--------

[](#security)

If you discover any security issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Morten Poul Jensen](https://github.com/pactode)
- [All contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 92.9% 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 ~117 days

Recently: every ~339 days

Total

15

Last Release

904d ago

Major Versions

v0.0.7 → v1.0.02019-06-04

v1.3.3 → v2.0.02023-11-21

PHP version history (3 changes)v0.0.1PHP ^7.1

v1.3.0PHP ^7.2.5

v1.3.3PHP ^7.2.5 || ^8.0

### Community

Maintainers

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

---

Top Contributors

[![pactode](https://avatars.githubusercontent.com/u/5956778?v=4)](https://github.com/pactode "pactode (65 commits)")[![telkins](https://avatars.githubusercontent.com/u/53731?v=4)](https://github.com/telkins "telkins (4 commits)")[![Razorsheep](https://avatars.githubusercontent.com/u/459217?v=4)](https://github.com/Razorsheep "Razorsheep (1 commits)")

---

Tags

apilaravelresponderresponse

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/signifly-laravel-api-responder/health.svg)

```
[![Health](https://phpackages.com/badges/signifly-laravel-api-responder/health.svg)](https://phpackages.com/packages/signifly-laravel-api-responder)
```

###  Alternatives

[spatie/laravel-query-builder

Easily build Eloquent queries from API requests

4.4k26.9M220](/packages/spatie-laravel-query-builder)[essa/api-tool-kit

set of tools to build an api with laravel

52680.5k](/packages/essa-api-tool-kit)[simplestats-io/laravel-client

Client for SimpleStats!

4515.5k](/packages/simplestats-io-laravel-client)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[ryangjchandler/bearer

Minimalistic token-based authentication for Laravel API endpoints.

8129.8k](/packages/ryangjchandler-bearer)

PHPackages © 2026

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