PHPackages                             arhamlabs/error-handler - 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. arhamlabs/error-handler

ActiveProject[API Development](/categories/api)

arhamlabs/error-handler
=======================

This package is a template used to create API responses which can be overwritten

2.1.2(2y ago)01911PHP

Since Dec 8Pushed 2y agoCompare

[ Source](https://github.com/arham-labs/error-handler-laravel)[ Packagist](https://packagist.org/packages/arhamlabs/error-handler)[ RSS](/packages/arhamlabs-error-handler/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (17)Used By (1)

Error Handler Package
=====================

[](#error-handler-package)

This package is a template used to create API responses which can be overwritten as per the developer's requirements.

**Installation:**
-----------------

[](#installation)

In order to install the package use the command specified below -

> composer require arhamlabs/error-handler

In **config/app.php** append the class in the providers array to publish the package service provider

> Arhamlabs\\ApiResponse\\ApiResponseServiceProvider::class

*Refer the image given below -*

[![Provider Image](assets/config-app-provider.JPG?raw=true "Title")](assets/config-app-provider.JPG?raw=true)

To publish the packages resources and configs run the command below

> php artisan vendor:publish --provider="Arhamlabs\\ApiResponse\\ApiResponseServiceProvider"

### **Notifications:**

[](#notifications)

Developers have the option to enable notifications **(implements queues)** through **emails and slack channels** in case of a code breakage or server errors. Once you have published the package resource you can see a new config file being created **(config/apiResponse.php)** to customize your notification options. You can open the config file which will have an array of params that will be required to enable notifications.

**Note: You may need to create a script to run queue (supervisor or cron jobs) in order for the notifications to work**

for more information of queues refer laravel documentation for **queues and supervisor**

>

**Usage:**
----------

[](#usage)

After installing the package, you may need to import the package in the file you want to use. Use the following import syntax

> use Arhamlabs\\ApiResponse\\ApiResponse;

*For using the package refer the image given below -*

[![Code Block](assets/example-code-1.JPG?raw=true "Title")](assets/example-code-1.JPG?raw=true)

### ***Get Response function:***

[](#get-response-function)

In the above example, we can see a function getResponse being called, this function returns a body response in a certain format that contains data and acknowledgement to users on success, whereas debugging information on errors.

> public function getResponse($statusCode=null, $data=null, $message=null, $file=null, $line=null, $errors=null)

- ### ***statusCode***

    [](#statuscode)

This parameter is the error code that we get in the response, typically 200 on success, 500 on error an so on. If this parameter is not defined, then the function sent a default status code of 500

- ### ***data***

    [](#data)

Typically defined when we need to send some data along with the response **(mostly used in status code 200)**.

- ### ***message***

    [](#message)

Message parameter contains a string that summarizes the response status.

- ### ***file***

    [](#file)

The file in which the error has occurred can be specified in this parameter

- ### ***line***

    [](#line)

We can also provide the line on which the error has occurred by ***$e-&gt;getLine()*** function in catch block ***(where $e is the object on class Exception)***

- ### ***errors***

    [](#errors)

This parameter can either be a string or an array errors, this is made standardized so that the front end team don't have to code for different type of datatype and structures

### ***Set Custom Response function:***

[](#set-custom-response-function)

In a scenario where the developer needs to use their own response and user message instead of the default configured messages, we may use this function to set those parameters in the response.

> public function setCustomResponse($messageTitle=null, $messageText=null, $primaryAction=null, $primaryActionLabel=null, $secondaryAction=null, $secondaryActionLabel=null)

- ### ***messageTitle***

    [](#messagetitle)

First parameter is the message title that is shown to the user.

- ### ***messageText***

    [](#messagetext)

This is the text that is shown to the user.

- ### ***primaryAction***

    [](#primaryaction)

The primary action is something that the user needs to do after they get a response from the api for instance - if a user tries to login with incorrect credentials, the primary action for this response was dismiss and try again with different credentials.

- ### ***primaryActionLabel***

    [](#primaryactionlabel)

The name on the widget that triggers the primary action

- ### ***secondaryAction***

    [](#secondaryaction)

The secondary action is an alternative action that a user can proceed with like cancel or dismiss and so on.

- ### ***secondaryActionLabel***

    [](#secondaryactionlabel)

The name on the widget that triggers the secondary action

### ***Set Custom Error function:***

[](#set-custom-error-function)

Where the developer needs to override default errors execution for instance, if a developer is not using default request files for validation and need to validate inside a controller itself, in this situation they may have to overwrite the errors to the validator errors before throwing to the catch block. Here the set custom error function may be useful.

> public function setCustomErrors($errors)

- ### ***errors***

    [](#errors-1)

The parameter passed to overwrite the default error, this can be either a string or an array (preferably validators errors object)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity54

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

Recently: every ~114 days

Total

16

Last Release

746d ago

Major Versions

1.0.8 → 2.0.02023-02-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/316ab3989a98e09c181970866b2bd1e75affeb999e34ea6b9412490e7cfec246?d=identicon)[Arham Labs](/maintainers/Arham%20Labs)

---

Top Contributors

[![rohanArhamLabs](https://avatars.githubusercontent.com/u/111741966?v=4)](https://github.com/rohanArhamLabs "rohanArhamLabs (18 commits)")

### Embed Badge

![Health badge](/badges/arhamlabs-error-handler/health.svg)

```
[![Health](https://phpackages.com/badges/arhamlabs-error-handler/health.svg)](https://phpackages.com/packages/arhamlabs-error-handler)
```

###  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)
