Download the PHP package wellrested/error-handling without Composer

On this page you can find all versions of the php package wellrested/error-handling. 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-handling

Error Handling

Provides classes to facilitate error handling with WellRESTed.

ErrorHandler and its subclasses provide human-readable default responses for responses with error status codes. The package includes concrete class that are ready to be dropped into you project as well as an abstract base class for creating completely custom error responses.

Catcher wraps a sequence of middleware in a try/catch block to allow recovery from exceptions. Catcher also provides response status codes for HttpExceptions.

Install

Add this package to your composer.json

Error Handler

ErrorHandler and its concrete subclasses provide human-readable responses for responses with status codes >= 400. To use, add an ErrorHandler subclass to your Server before the middleware that may return an error response.

Text- and HtmlErrorHandler

When the router fails to match a route (or middleware returns a response with a 404 status code), the TextErrorHandler provides a plain/text response:

Or, if you're prefer HTML, use the HtmlErrorHandler.

Custom Error Handlers

To provide your own custom error responses, subclass WellRESTed\ErrorHandling\ErrorHandler and implement provideResponseForError. This method expects a request and response as parameters and returns the updated response.

You do not need to check whether or not to handle the response; the ErrorHandler instance calls provideResponseForError only when:

Here's an example that provides a silly response for 404 errors, and normal responses for all other errors.

Catcher

A Catcher instance wraps a sequence of middleware in a try/catch block to allow for recovery from exceptions.

Catcher may be used "out-of-the-box" to provide response status codes for HttpExceptions, or you can subclass it to respond to other Exceptions.

Basic Usage

Add a Catcher to your server and add middleware to it using the Catcher::add method. Be sure to pass a reference to a dispatcher (an instance implementing WellRESTed\Dispatching\DispatcherInterface) to the constructor. The Server provides access to the dispatcher it uses via Server::getDispatcher.

When any middleware contained in the Catcher throws an HttpException, the catcher will return a response with a status code matching the HttpException's code. For example, throwing a ConflictException results in a 409 Conflict status.

NOTE: When middleware throws an exception, the execution jumps directly to the Catcher and does not work its way back down through the chain of middleware. This may be useful if you want to provide an immediate out for your response.

Custom Exceptions

To catch exceptions other than HttpExceptions, subclass Catcher and implement the getResponseForException method.

Catching and Handling

Catcher and ErrorHandler make a great team. Add an ErrorHandler in front of your Catcher to provide default responses for exceptions.

Copyright and License

Copyright © 2015 by PJ Dietz Licensed under the MIT license


All versions of error-handling with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
wellrested/wellrested Version ^3.0.0
wellrested/http-exceptions Version ^1.0.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 wellrested/error-handling contains the following files

Loading the files please wait ....