PHPackages                             fake-fakers/laravel-api-components - 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. fake-fakers/laravel-api-components

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

fake-fakers/laravel-api-components
==================================

Set of useful Laravel components

1.0.1(5y ago)07MITPHPPHP &gt;=7.2

Since Oct 29Pushed 5y ago1 watchersCompare

[ Source](https://github.com/fake-fakers/laravel_api_components)[ Packagist](https://packagist.org/packages/fake-fakers/laravel-api-components)[ RSS](/packages/fake-fakers-laravel-api-components/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Laravel Api Components
======================

[](#laravel-api-components)

Components list
---------------

[](#components-list)

### Middleware

[](#middleware)

1. `PreferJson` - a simple middleware that can be used in api routes, to prefer JSON-responses instead of default HTML. Also has an option to force JSON output even if Accept header is present.

### Helper functions

[](#helper-functions)

1. `formatValidationErrors` - transforms ValidationException to array.
2. `escapeStringForSqlLike` - escape string to use it in SQL LIKE queries.

### Exceptions handler

[](#exceptions-handler)

Provides a simple way to define application exception handlers.
Usage:

1. Inherit `app/Exception/Handler.php` class from exception handler from this package: ```
    use Brainex\ApiComponents\Exceptions\BaseHandler;

    class Handler extends BaseHandler
    {
       // write your code here
    }
    ```
2. Define your own exception handlers: ```
        /**
         * A list of custom exception handlers
         *
         * @return array
         */
        protected function getCustomHandlers(): array
        {
            return [
                OAuthServerException::class => [$this, 'oauthServerJson']
            ];
        }

        /**
         * Get JsonResponse for OAuthServerException exception
         *
         * @param OAuthServerException $exception
         * @return JsonResponse
         */
        protected function oauthServerJson(OAuthServerException $exception): JsonResponse
        {
            return \response()->json([
                'message' => $exception->getErrorType(),
                'data' => [
                    'description' => $exception->getMessage(),
                    'hint' => $exception->getHint()
                ]
            ], $exception->getHttpStatusCode(), $exception->getHttpHeaders());
        }
    ```

### Service provider

[](#service-provider)

1. `RoutingServiceProvider` - overriding Laravel's default Router and ResponseFactory to return JSON responses with `JSON_UNESCAPED_UNICODE`.
    Usage:
    1. Create `Application` class in your app folder: ```
        declare(strict_types=1);

        namespace App;

        use Illuminate\Log\LogServiceProvider;
        use Illuminate\Events\EventServiceProvider;

        /**
         * Class Application
         * @package App
         *
         * Overriding original application to hook router
         */
        class Application extends \Illuminate\Foundation\Application
        {
            /**
             * Register all of the base service providers.
             *
             * @return void
             */
            protected function registerBaseServiceProviders(): void
            {
                $this->register(new EventServiceProvider($this));

                $this->register(new LogServiceProvider($this));

                // hook responses to make them JSON_UNESCAPED_UNICODE
                $this->register(new \Brainex\ApiComponents\Routing\RoutingServiceProvider($this));
            }
        }
        ```
    2. Patch `bootstrap/app.php` file to create new `Application` class instead of Laravel's default: ```
        $app = new \App\Application(
            realpath(__DIR__.'/../')
        );
        ```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

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

2021d ago

### Community

Maintainers

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

### Embed Badge

![Health badge](/badges/fake-fakers-laravel-api-components/health.svg)

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

###  Alternatives

[wireui/wireui

TallStack components

1.8k1.3M16](/packages/wireui-wireui)[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4195.3M84](/packages/livewire-volt)[ramonrietdijk/livewire-tables

Dynamic tables for models with Laravel Livewire

21147.4k](/packages/ramonrietdijk-livewire-tables)

PHPackages © 2026

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