Download the PHP package robrogers3/laravel-jsonaware-exception-handler without Composer

On this page you can find all versions of the php package robrogers3/laravel-jsonaware-exception-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 laravel-jsonaware-exception-handler

Latest Version on Packagist Total Downloads Build Status

Laravel Json Aware Exception Handler

Every one likes cool error message pages. Github has an awesome 404.

And it's very easy to create your own custom error pages for html responses.

But doing this for Ajax and Json responses meant either doing something generic or figuring out your own solution. Often something like returning an error message like 'Sorry we cant handle your request'. Nothing informative.

This package solves this problem.

Once it's installed. Tune your error messages for over a dozen possible error codes. You can even add more. Just create a ZizzZazzException assign a status code to it, and a custom message. Done!

Installation

Install Laravel Json Aware Exception Handler with Composer.

Configuration

Using it:

Option 1: Update your .env file by adding this line:

USE_JSON_EXCEPTION_HANDLER=true

This will use the JsonHandler for json requests and the Laravel Exception Handler for regular requests.

Note: it will completely ignore your app's Exception Handler. This means you can't override anything in this class.

Option 2: Update your App Handler class to extend the JsonAwareExceptionHandler

You do not have to update your .env file.

The benefit of this is you can overide how the JsonAwareExceptionHandler

To do this you need to change your App\Exceptions\Handler class to extend RobRogers3\LaravelExceptionHandler\JsonAwareExceptionHandler rather than extending Illuminate\Foundation\Exceptions\Handler. Like so:

Last Step

You need to run this artisan command:

This will copy the exception messages to your local lang directory.

Optional Setup.

Open the exceptionmessages.php and change the messages you want to show for different http status codes.

You may want to change 401 to something more clever or more corporate. It's up to you.

Usage

Server Side Usage

There really is only one thing to use: Taking advantage of the MessagingException::class

Throwing this with a custom message allows you to display something detailed or specific to the situtation.

Client Side Usage with Ajax

Here's where you want to take advantage of this.

Take a look at this handling of an ajax response error.


All versions of laravel-jsonaware-exception-handler with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
illuminate/contracts Version >=5.3
illuminate/support Version >=5.3
symfony/debug Version ^2.7|^3.0
symfony/http-foundation Version ^2.7|^3.0
psr/log Version ^1.0
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 robrogers3/laravel-jsonaware-exception-handler contains the following files

Loading the files please wait ....