Skip to content

Commit 2fb8544

Browse files
Merge pull request #167 from MarcinOrlowski/dev
Release v9.0.2
2 parents d00eb52 + 7269a2d commit 2fb8544

38 files changed

+899
-820
lines changed

.github/stale.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Number of days of inactivity before an issue becomes stale
2+
daysUntilStale: 21
3+
# Number of days of inactivity before a stale issue is closed
4+
daysUntilClose: 7
5+
# Issues with these labels will never be considered stale
6+
exemptLabels:
7+
- pinned
8+
- security
9+
# Label to use when marking an issue as stale
10+
staleLabel: wontfix
11+
# Comment to post when marking an issue as stale. Set to `false` to disable
12+
markComment: >
13+
This issue has been automatically marked as stale because it has not had
14+
recent activity and will be closed soon as such.
15+
# Comment to post when closing a stale issue. Set to `false` to disable
16+
closeComment: >
17+
This stale issue has been automatically closed. Feel free to still comment
18+
and even reopen the ticket if the problem is not solved or you think we
19+
could go better. Thank you for your contributions.

CHANGES.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22

33
# REST API Response Builder for Laravel #
44

5-
This library follows [Semantic versioning](https://semver.org).
5+
This library follows [Semantic versioning](https://semver.org).
66
See [compatibility docs](docs/compatibility.md) for details about backward compatibility
77
before doing major upgrade!
88

99
## CHANGE LOG ##
1010

11+
* v9.0.2 (2020-10-24)
12+
* Corrected tests to use regular ServiceProvider.
13+
* Corrected primitive converter tests.
14+
* Presence of configuration "converter/classes" array is now mandatory (reported by Raja)
15+
* Extensive documentation overhaul
16+
1117
* v9.0.1 (2020-10-22)
1218
* Fixed auto-discovery failing due to broken `ServiceProvider` (reported by Efriandika Pratama).
1319
* Corrected documentation and usage examples.

README.md

Lines changed: 7 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,13 @@
1010
[![Monthly Downloads](https://poser.pugx.org/marcin-orlowski/laravel-api-response-builder/d/monthly)](https://packagist.org/packages/marcin-orlowski/laravel-api-response-builder)
1111
[![License](https://poser.pugx.org/marcin-orlowski/laravel-api-response-builder/license)](https://packagist.org/packages/marcin-orlowski/laravel-api-response-builder)
1212

13-
[![SensioLabs Insight](https://insight.sensiolabs.com/projects/5c5f4dc1-41d5-49f9-b4ba-6268aa3fea00/big.png)](https://insight.sensiolabs.com/projects/5c5f4dc1-41d5-49f9-b4ba-6268aa3fea00)
14-
15-
[![Unstable Version](https://poser.pugx.org/marcin-orlowski/laravel-api-response-builder/v/unstable)](https://packagist.org/packages/marcin-orlowski/laravel-api-response-builder)
16-
[![Unstable Build Status](https://travis-ci.org/MarcinOrlowski/laravel-api-response-builder.svg?branch=dev)](https://travis-ci.org/MarcinOrlowski/laravel-api-response-builder)
17-
[![Ustable Code Quality](https://scrutinizer-ci.com/g/MarcinOrlowski/laravel-api-response-builder/badges/quality-score.png?b=dev)](https://scrutinizer-ci.com/g/MarcinOrlowski/laravel-api-response-builder/?branch=dev)
18-
[![Unstble Code Coverage](https://scrutinizer-ci.com/g/MarcinOrlowski/laravel-api-response-builder/badges/coverage.png?b=dev)](https://scrutinizer-ci.com/g/MarcinOrlowski/laravel-api-response-builder/?branch=dev)
19-
2013
## Table of contents ##
2114

2215
* [Introduction](#introduction)
2316
* [Why should I use it?](#benefits)
24-
* [Usage examples](#usage-examples)
17+
* [Usage examples](docs/examples.md#usage-examples)
2518
* [Features](#features)
26-
* [Documentation](docs/docs.md)
27-
* [Requirements](docs/docs.md#requirements)
28-
* [Installation and Configuration](docs/docs.md#installation-and-configuration)
19+
* [Extensive documentation](docs/README.md)
2920
* [License](#license)
3021
* [Changelog](CHANGES.md)
3122

@@ -35,8 +26,8 @@
3526

3627
## Introduction ##
3728

38-
`ResponseBuilder` is a [Laravel](https://laravel.com/) helper designed to build nice, normalized and easy to consume REST API
39-
JSON responses.
29+
`ResponseBuilder` is a [Laravel](https://laravel.com/) package, designed to help you build a nice, normalized and easy to consume
30+
REST API JSON responses.
4031

4132
## Benefits ##
4233

@@ -53,94 +44,17 @@
5344
Did I mention, you would also get testing traits that automatically unit test your whole `ResponseBuilder` related code
5445
and configuration with just a few lines of code?
5546

56-
## Usage examples ##
57-
58-
Operation successful? Conclude your controller method with:
59-
60-
```php
61-
return RB::success();
62-
```
63-
64-
and your client will get nice JSON like
65-
66-
```json
67-
{
68-
"success": true,
69-
"code": 0,
70-
"locale": "en",
71-
"message": "OK",
72-
"data": null
73-
}
74-
```
75-
76-
Need to additionally return extra payload with the response? Pass it as
77-
argument to `success()`:
78-
79-
```php
80-
$flight = App\Flight::where(...)->get();
81-
return RB::success($flight);
82-
```
83-
84-
and your client will get that data in `data` node of your response:
85-
86-
```json
87-
{
88-
"success": true,
89-
"code": 0,
90-
"locale": "en",
91-
"message": "OK",
92-
"data": {
93-
"items": [
94-
{
95-
"airline": "lot",
96-
"flight_number": "lo123",
97-
...
98-
},
99-
{
100-
"airline": "american",
101-
"flight_number": "am456",
102-
...
103-
}
104-
]
105-
}
106-
}
107-
```
108-
109-
Something went wrong and you want to tell the clinet about that? Just do:
110-
111-
```php
112-
return RB::error(250);
113-
```
114-
115-
The following JSON response will then be returned:
116-
117-
```json
118-
{
119-
"success": false,
120-
"code": 250,
121-
"locale": "en",
122-
"message": "Your error message for code 250",
123-
"data": null
124-
}
125-
```
126-
127-
Nice and easy! And yes, `message` can be easily customized! Also there're **much, much more** you can do with
128-
rich `ResponseBuilder` API. See [library documentation](docs/docs.md) for details and more examples!
129-
130-
----
131-
13247
## Features ##
13348

134-
* Easy to use,
49+
* [Easy to use](docs/README.md#usage-examples),
13550
* [Stable and production ready](https://travis-ci.org/MarcinOrlowski/laravel-api-response-builder),
136-
* On-the-fly data object conversion,
51+
* [On-the-fly data object conversion](docs/conversion.md),
13752
* API chaining support,
138-
* Localization support,
53+
* [Localization support](docs/docs.md#messages-and-localization),
13954
* Provides traits to help [unit test your API code](docs/testing.md),
14055
* Comes with [exception handler helper](docs/exceptions.md) to ensure your API stays consumable even in case of unexpected,
14156
* No additional dependencies.
14257

143-
----
14458

14559
## License ##
14660

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "marcin-orlowski/laravel-api-response-builder",
33
"description": "Helps building nice, normalized and easy to consume Laravel REST API.",
44
"homepage": "https://github.com/MarcinOrlowski/laravel-api-response-builder",
5-
"version": "9.0.1",
5+
"version": "9.0.2",
66
"keywords": [
77
"laravel",
88
"json",
@@ -46,7 +46,7 @@
4646
},
4747
"require-dev": {
4848
"marcin-orlowski/coding-standard": "^1.3",
49-
"marcin-orlowski/phpunit-extra-asserts": "^1.1",
49+
"marcin-orlowski/phpunit-extra-asserts": "^1.2.0",
5050
"orchestra/testbench": "^4.0",
5151
"phpunit/phpunit": "^8.0",
5252
"phpunit/php-code-coverage": "^7.0",

docs/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
![REST API Response Builder for Laravel](docs/img/logo.png)
2+
3+
# REST API Response Builder for Laravel #
4+
5+
`ResponseBuilder` is [Laravel](https://laravel.com/)'s helper designed to build
6+
nice, normalized and easy to consume REST API JSON responses.
7+
8+
## Table of contents ##
9+
10+
* [Fundamentals](docs.md)
11+
* [Requirements](requirements.md)
12+
* [Installation](installation.md)
13+
* [Configuration](config.md)
14+
* [On-the-fly data conversion](conversion.md)
15+
* [Usage examples](examples.md)
16+
* [Exposed methods](methods.md)
17+
* [Manipulating response JSON object](response.md)
18+
* [Exception Handling](exceptions.md)
19+
* [Unit testing](testing.md)
20+
* [Important incompatibile changes](compatibility.md)
21+
22+
**Upgrading from previous version? Check [compatibility docs](compatibility.md) prior altering your `composer.json`!**
23+

docs/compatibility.md

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
![REST API Response Builder for Laravel](img/logo.png)
22

3-
# REST API Response Builder for Laravel #
3+
# Backward compatibility #
44

5+
[« Documentation table of contents](README.md)
56

6-
### v9 ###
7+
* [Important incompatibile changes](#incompatibility-notes)
8+
* [Changes in v9](#v9)
9+
* [Changes in v8](#v8)
10+
* [Changes in v7](#v7)
11+
* [Changes in v6](#v6)
12+
* [Changes in v5](#v5)
13+
* [Changes in v4](#v4)
14+
* [Changes in v3](#v3)
15+
* [Changes in v2](#v2)
16+
* [Changes in v1](#v1)
17+
18+
---
19+
20+
# Incompatibility notes #
21+
22+
Backward (in)compatibility notes. Pay attention if you are upgrading.
23+
24+
## v9 ##
725

826
* `[BREAKING]` Due to introduction of primitives support as direct payload, structure of `converter` config entry changed.
927
* `[BREAKING]` Due to introduction of primitives support as direct payload, the content of `data` object in the response may differ
@@ -16,14 +34,14 @@
1634
* `[Low]` For better error reporting and handling, `ResponseBuilder` throws own, more descriptive exceptions in majority of cases. See [src/Exceptions](../src/Exceptions).
1735

1836

19-
### v8 ###
37+
## v8 ##
2038

2139
* `[BREAKING]` Due to introduction of exception handlers, `ExceptionHandler` configuration has been changed.
2240
See [configuration docs](config.md#exception_handler) for more information.
2341
* `[Very Low]` Removed `ResponseBuilderLegacy` class from the package.
2442

2543

26-
### v7 ###
44+
## v7 ##
2745

2846
* `[BREAKING]` As the library API migrated to Builder type of implementation, all the former API methods are now removed from
2947
`ResponseBuilder` class (with exception for `success()` and `error()` methods. While it is strongly recommended to switch
@@ -41,7 +59,7 @@
4159
feature **AND** pass objects directly (i.e. not as part of collection nor array).
4260

4361

44-
### v6 ###
62+
## v6 ##
4563

4664
* Requires Laravel 6.0+ and PHP 7.2+
4765
* `[BREAKING]` In previous versions built-in reserved codes were hardcoded and always in range of 1-63 which, in general
@@ -68,24 +86,24 @@
6886
library. From now one you need to stick to default names now (`success`, `code`, `message`, `locale`, `data`).
6987
* `[Very Low] (v6.2)` Data conversion logic changed slightly. Now it checks if we have configuration entry matching **exactly**
7088
the object's class name. If not, then we'd try to find if we have any configuration for its parent class.
71-
See [Data Conversion](docs.md#data-conversion) for details.
89+
See [Data Conversion](conversion.md) for details.
7290
* `[BREAKING] (v6.3)` This is backward incompatible change in signature of `RB::buildResponse()`, but it only affects
7391
you if you extend `ResponseBuilder` and provide own implementation to manipulate response object
74-
(see [Manipulating Response Object](docs.md#manipulating-response-object)). If you do not, then you are not affected.
92+
(see [Manipulating Response Object](response.md)). If you do not, then you are not affected.
7593

7694

77-
### v5 ###
95+
## v5 ##
7896

7997
* No public release.
8098

8199

82-
### v4 ###
100+
## v4 ##
83101

84102
* `ApiCodeBase` class is now `BaseApiCodes`
85103
* ExceptionHandler's debug trace no longer depends on `APP_DEBUG` value and can be enabled independently
86104

87105

88-
### v3 ###
106+
## v3 ##
89107

90108
* `success()` now accepts (optional) `api_code` too, therefore signature of this method as well as and argument
91109
order changed. This makes it **partially** incompatible with what have been in v2, however in majority of uses

0 commit comments

Comments
 (0)