PHPackages                             motrack/hoodie - 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. motrack/hoodie

ActiveLibrary[API Development](/categories/api)

motrack/hoodie
==============

a wrapper for managing api response

1.2.1(2y ago)2516MITPHP

Since Mar 29Pushed 2y ago2 watchersCompare

[ Source](https://github.com/prpahlevani/hoodie)[ Packagist](https://packagist.org/packages/motrack/hoodie)[ RSS](/packages/motrack-hoodie/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (8)Used By (0)

hoodie
======

[](#hoodie)

This package provides you a regular uniformed JSON response structure.

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

[](#installation)

```
$ composer require motrack/hoodie
```

### For Laravel version &lt; 5.5

[](#for-laravel-version--55)

If you don't use auto-discovery, add the ServiceProvider to the providers array in `config/app.php`

```
Motrack\Hoodie\Providers\HoodieServiceProvider::class,
```

you can add the facade name as an alias to the `config/app.php`

```
"aliases": {
    "Hoodie" => Motrack\Hoodie\Facades\Hoodie::class
}
```

or just add the facade class wherever you need.

```
use Motrack\Hoodie\Facades\Hoodie
```

Basic Usage
-----------

[](#basic-usage)

there are two basic methods `respondSuccess()` and `respondError()` for the general response managing. for example you can easily make a response in your Controller using Hoodie

```
    public function doFunction(): JsonResponse
    {
        ...
        return Hoodie::respondSuccess();
    }
```

there are still options for customizing the response message, status code, or even setting some custom headers.

```
return Hoodie::respondSuccess('Success!', 200, ['token' => $token, 'platform' => 'core']);
```

you can even pass the exception through the `respondError()` method to manage the response error when the `APP_DEBUG` is `true` in your `.env` file, if you wish.

```
return Hoodie::respondError('Something went wrong!', 500, $exception, $headers );
```

Advanced Usage
--------------

[](#advanced-usage)

if you want to pass your using resource through the result of the API response, you can call `respondWithResource()` method.

```
use App\Http\Resources\PostResource; // the Json Resource you've provided for the result

class PostController extends Controller
{
    ...
    public function show(Post $post): JsonResponse
    {
        return Hoodie::respondWithResource(new PostResource($post) , 'Post Created Successfully', 201 , ['my_custom_header' => 'header_value']);
    }
    ...
}
```

the `respondWithResourceCollection()` method is using for when you need to pass a Json Collection Resource through the result of your API.

```
use App\Http\Resources\PostCollection; // the Json Collection you've provided for the result

class PostController extends Controller
{
    public function index(): JsonResponse
    {
        return Hoodie::respondWithResourceCollection(new PostCollection(Post::paginate()) , 'List of Posts Retrieved Successfully', 200 , ['my_custom_header' => 'header_value']);
    }
    ...
}
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.2% 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 ~54 days

Recently: every ~79 days

Total

7

Last Release

811d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/372b8008262612d74baa9ccfe5c4baea1acb562ad8842fbe993afd4371a67d10?d=identicon)[prpahlevani](/maintainers/prpahlevani)

---

Top Contributors

[![prpahlevani](https://avatars.githubusercontent.com/u/26036791?v=4)](https://github.com/prpahlevani "prpahlevani (20 commits)")[![masoudmanson](https://avatars.githubusercontent.com/u/927990?v=4)](https://github.com/masoudmanson "masoudmanson (1 commits)")

---

Tags

responsejsonapilaravel

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/motrack-hoodie/health.svg)

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

###  Alternatives

[obiefy/api-response

Simple Laravel package to return Json responses.

17324.6k](/packages/obiefy-api-response)[nilportugues/laravel5-json-api-dingo

Laravel5 JSONAPI and Dingo together to build APIs fast

311.5k](/packages/nilportugues-laravel5-json-api-dingo)[nilportugues/laravel5-haljson

Laravel 5 HAL+JSON API Transformer Package

151.0k](/packages/nilportugues-laravel5-haljson)[nicklaw5/larapi

A simple Laravel 5 class for handling json api responses.

111.5k](/packages/nicklaw5-larapi)

PHPackages © 2026

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