PHPackages                             jerrydepredator/laravel-predator-api-utils - 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. jerrydepredator/laravel-predator-api-utils

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

jerrydepredator/laravel-predator-api-utils
==========================================

A collection of utility classes and traits to streamline common Laravel development tasks, including error handling, paginated responses, data handling, middleware creation, a base repository for advanced filtering, keyset pagination, base query filtering, and more. This package aims to reduce boilerplate code often encountered in Laravel projects.

v0.0.9(1y ago)097MITPHPPHP ^8.2

Since Dec 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/jeremiah-olisa/laravel-predator-api-utils)[ Packagist](https://packagist.org/packages/jerrydepredator/laravel-predator-api-utils)[ RSS](/packages/jerrydepredator-laravel-predator-api-utils/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (9)Dependencies (4)Versions (10)Used By (0)

Laravel Predator API Utils
==========================

[](#laravel-predator-api-utils)

This package provides a collection of utility classes and traits to streamline common Laravel development tasks, such as:

- **Error Handling:** Easily handle and format API errors.
- **Paginated Responses:** Create paginated responses with consistent structure.
- **Data Handling:** Simplify data manipulation and extraction.
- **Middleware:** Implement custom middleware for authentication, authorization, and other cross-cutting concerns.
- **Repository Pattern:** Provides a base repository class for common database operations.

⚠️⚠️ Disclaimer ⚠️⚠️
--------------------

[](#️️-disclaimer-️️)

> This package aims to reduce boilerplate code often encountered in "MY LARAVEL PROJECTS" by providing reusable components. It was created based on my personal preferences and may not be suitable for all projects or development styles. It is not intended to be a comprehensive solution for all Laravel development needs and may require customization for specific requirements.

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

[](#installation)

1. **Install via Composer:**

    ```
    composer require jerrydepredator/laravel-predator-api-utils
    ```
2. **Publish Configuration (Optional):**

    - If you want to customize the default property names for the `DecryptedJWToken` service, publish the configuration file:

        ```
        php artisan vendor:publish --provider="LaravelPredatorApiUtils\ServiceProvider" --tag="config"
        ```
    - This will create a `config/decrypted_jwt_token.php` file in your project where you can modify the property names.

Usage
-----

[](#usage)

### 1. DecryptedJWTToken Service:

[](#1-decryptedjwttoken-service)

- **Location:** `src/Services/DecryptedJWToken.php`
- **Purpose:** Provides methods to access data from a decrypted JWT token.
- **Usage:**

    ```
    use LaravelPredatorApiUtils\Services\DecryptedJWToken;

    // In your controller
    public function showProfile(Request $request, DecryptedJWToken $decryptedJWToken)
    {
        $userId = $decryptedJWToken->getUserId();
        $userName = $decryptedJWToken->getUserName();
        $userData = $decryptedJWToken->getData(); // Get all user data

        // ... your logic using user data
    }
    ```

### 2. Middlewares:

[](#2-middlewares)

- **DecryptJWToken:**

    - **Location:** `src/Middlewares/DecryptJWToken.php`
    - **Purpose:** Decrypts the JWT token from the `Authorization` header and adds the decrypted data to the request object.
    - **Usage:**
        - Register the middleware in `app/Http/Kernel.php`:

            ```
            protected $routeMiddleware = [
                // ... other middleware
                'decrypt_jwt' => \App\Http\Middleware\DecryptJWToken::class,
            ];
            ```
        - Apply the middleware to routes:

            ```
            Route::get('/protected-route', [MyController::class, 'showData'])->middleware('decrypt_jwt');
            ```
- **RoleMiddleware:**

    - **Location:** `src/Middlewares/RoleMiddleware.php`
    - **Purpose:** Restricts access to routes based on user roles.
    - **Usage:**
        - Register the middleware in `app/Http/Kernel.php`:

            ```
            protected $routeMiddleware = [
                // ... other middleware
                'role' => \App\Http\Middleware\RoleMiddleware::class,
            ];
            ```
        - Apply the middleware to routes:

            ```
            Route::get('/admin', [AdminController::class, 'index'])->middleware('role:admin');
            ```

### 3. Traits:

[](#3-traits)

- **ApiResponse:**

    - **Location:** `src/Traits/ApiResponse.php`
    - **Purpose:** Provides helper methods for creating API responses with standardized structures.
- **HandlesErrors:**

    - **Location:** `src/Traits/HandlesErrors.php`
    - **Purpose:** Provides helper methods for handling and formatting API errors.
- **PaginationRules:**

    - **Location:** `src/Traits/PaginationRules.php`
    - **Purpose:** Provides rules for validating pagination parameters.

### 4. Repositories:

[](#4-repositories)

- **BaseRepository:**
    - **Location:** `src/Repositories/BaseRepository.php`
    - **Purpose:** Provides a base class for implementing repositories with common database operations.

Configuration:
--------------

[](#configuration)

- **`decrypted_jwt_token.php`:**
    - Located in the `config` directory.
    - Defines default property names for the `DecryptedJWToken` service.
    - Can be customized to match your specific JWT token structure.

Contributing
------------

[](#contributing)

Contributions are welcome! Please submit pull requests to the project's GitHub repository.

License
-------

[](#license)

This package is licensed under the MIT License.

###  Health Score

28

—

LowBetter than 51% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

Total

9

Last Release

556d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/31079573?v=4)[Jeremiah Olisa](/maintainers/jeremiah-olisa)[@jeremiah-olisa](https://github.com/jeremiah-olisa)

---

Top Contributors

[![jeremiah-olisa](https://avatars.githubusercontent.com/u/31079573?v=4)](https://github.com/jeremiah-olisa "jeremiah-olisa (15 commits)")

### Embed Badge

![Health badge](/badges/jerrydepredator-laravel-predator-api-utils/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k113.1M998](/packages/laravel-socialite)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.6k31.8M162](/packages/laravel-cashier)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[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.

45844.8k1](/packages/pressbooks-pressbooks)[aedart/athenaeum

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

265.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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