Download the PHP package arhamlabs/error-handler without Composer

On this page you can find all versions of the php package arhamlabs/error-handler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package error-handler

Error Handler Package

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


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 -

To publish the packages resources and configs run the command below

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


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

https://laravel.com/docs/9.x/queues


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 -


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)



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)


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

This is the text that is shown to the user.

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.

The name on the widget that triggers the primary action

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

The name on the widget that triggers the secondary action


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)


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


All versions of error-handler with dependencies

PHP Build Version
Package Version
Requires arhamlabs/notification_handler Version 1.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package arhamlabs/error-handler contains the following files

Loading the files please wait ....