|
1 | | -Api-Problem: ZF2 Module for API-Problem representations |
2 | | -======================================================= |
| 1 | +ZF Api Problem |
| 2 | +============== |
3 | 3 |
|
4 | 4 | [](https://travis-ci.org/zfcampus/zf-api-problem) |
5 | | -[](https://coveralls.io/r/zfcampus/zf-api-problem) |
| 5 | + |
| 6 | +Introduction |
| 7 | +------------ |
6 | 8 |
|
7 | 9 | This module provides data structures and rendering for the API-Problem format. |
8 | 10 |
|
9 | 11 | - [Problem API](http://tools.ietf.org/html/draft-nottingham-http-problem-05), |
10 | 12 | used for reporting API problems |
| 13 | + |
| 14 | + |
| 15 | +Installation |
| 16 | +------------ |
| 17 | + |
| 18 | +Run the following `composer` command: |
| 19 | + |
| 20 | +```console |
| 21 | +$ composer require "zfcampus/zf-api-problem:~1.0-dev" |
| 22 | +``` |
| 23 | + |
| 24 | +Alternately, manually add the following to your `composer.json`, in the `require` section: |
| 25 | + |
| 26 | +```javascript |
| 27 | +"require": { |
| 28 | + "zfcampus/zf-api-problem": "~1.0-dev" |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +And then run `composer update` to ensure the module is installed. |
| 33 | + |
| 34 | +Finally, add the module name to your project's `config/application.config.php` under the `modules` |
| 35 | +key: |
| 36 | + |
| 37 | +```php |
| 38 | +return array( |
| 39 | + /* ... */ |
| 40 | + 'modules' => array( |
| 41 | + /* ... */ |
| 42 | + 'ZF\ApiProblem', |
| 43 | + ), |
| 44 | + /* ... */ |
| 45 | +); |
| 46 | +``` |
| 47 | + |
| 48 | +Configuration |
| 49 | +------------- |
| 50 | + |
| 51 | +### User Configuration |
| 52 | + |
| 53 | +The top-level configuration key for user configuration of this module is `zf-api-problem`. |
| 54 | + |
| 55 | +#### Key: `accept_filters` |
| 56 | + |
| 57 | +// Accept types that should allow ApiProblem responses |
| 58 | + |
| 59 | +#### Key: `render_error_controllers` |
| 60 | + |
| 61 | +// Array of controller service names that should enable the ApiProblem render.error listener |
| 62 | + |
| 63 | + |
| 64 | +### System Configuration |
| 65 | + |
| 66 | +The following configuration is provided in `config/module.config.php` to enable the module to |
| 67 | +function: |
| 68 | + |
| 69 | +```php |
| 70 | +'service_manager' => array( |
| 71 | + 'aliases' => array( |
| 72 | + 'ZF\ApiProblem\ApiProblemListener' => 'ZF\ApiProblem\Listener\ApiProblemListener', |
| 73 | + 'ZF\ApiProblem\RenderErrorListener' => 'ZF\ApiProblem\Listener\RenderErrorListener', |
| 74 | + 'ZF\ApiProblem\ApiProblemRenderer' => 'ZF\ApiProblem\View\ApiProblemRenderer', |
| 75 | + 'ZF\ApiProblem\ApiProblemStrategy' => 'ZF\ApiProblem\View\ApiProblemStrategy', |
| 76 | + ), |
| 77 | + 'factories' => array( |
| 78 | + 'ZF\ApiProblem\Listener\ApiProblemListener' => 'ZF\ApiProblem\Factory\ApiProblemListenerFactory', |
| 79 | + 'ZF\ApiProblem\Listener\RenderErrorListener' => 'ZF\ApiProblem\Factory\RenderErrorListenerFactory', |
| 80 | + 'ZF\ApiProblem\Listener\SendApiProblemResponseListener' => 'ZF\ApiProblem\Factory\SendApiProblemResponseListenerFactory', |
| 81 | + 'ZF\ApiProblem\View\ApiProblemRenderer' => 'ZF\ApiProblem\Factory\ApiProblemRendererFactory', |
| 82 | + 'ZF\ApiProblem\View\ApiProblemStrategy' => 'ZF\ApiProblem\Factory\ApiProblemStrategyFactory', |
| 83 | + ) |
| 84 | +), |
| 85 | +'view_manager' => array( |
| 86 | + // Enable this in your application configuration in order to get full |
| 87 | + // exception stack traces in your API-Problem responses. |
| 88 | + 'display_exceptions' => false, |
| 89 | +), |
| 90 | +``` |
| 91 | + |
| 92 | +ZF2 Events |
| 93 | +---------- |
| 94 | + |
| 95 | +### Listeners |
| 96 | + |
| 97 | +#### `ZF\ApiProblem\ApiProblemListener` (a.k.a. `ZF\ApiProblem\Listener\ApiProblemListener`) |
| 98 | + |
| 99 | +#### `ZF\ApiProblem\RenderErrorListener` (a.k.a. `ZF\ApiProblem\Listener\RenderErrorListener`) |
| 100 | + |
| 101 | +#### `ZF\ApiProblem\Listener\SendApiProblemResponseListener` |
| 102 | + |
| 103 | + |
| 104 | +ZF2 Services |
| 105 | +------------ |
| 106 | + |
| 107 | +### Event Services |
| 108 | + |
| 109 | +- `ZF\ApiProblem\Listener\ApiProblemListener` |
| 110 | +- `ZF\ApiProblem\Listener\RenderErrorListener` |
| 111 | +- `ZF\ApiProblem\Listener\SendApiProblemResponseListener` |
| 112 | + |
| 113 | +### View Services |
| 114 | + |
| 115 | +#### `ZF\ApiProblem\ApiProblemRenderer` (a.k.a. `ZF\ApiProblem\View\ApiProblemRenderer`) |
| 116 | + |
| 117 | +#### `ZF\ApiProblem\ApiProblemStrategy` (a.k.a. `ZF\ApiProblem\View\ApiProblemStrategy`) |
| 118 | + |
0 commit comments