115
115
### Builder ###
116
116
117
117
To obtain instance of the Builder, two static methods: `asSuccess()` and `asError()` are now exposed. For example, the following
118
- code would success with data and custom HTTP code:
118
+ code would return response indicating a success, with additional data and custom HTTP code:
119
119
120
120
```php
121
121
return ResponseBuilder::asSuccess()
@@ -124,14 +124,17 @@ return ResponseBuilder::asSuccess()
124
124
->build();
125
125
```
126
126
127
- For simplicity of use, it's recommended to add the following ` use ` to your code:
127
+ For simplicity of use, it's recommended to add the following ` use ` to your code (you can also use
128
+ [ namespace aliasing] ( https://www.php.net/manual/en/language.namespaces.importing.php ) ):
128
129
129
130
use MarcinOrlowski\ResponseBuilder\ResponseBuilder;
130
131
132
+ If you dislike typing ` ResponseBuilder ` you can use [ namespace aliasing] ( https://www.php.net/manual/en/language.namespaces.importing.php ) :
133
+
131
134
Builder static methods:
132
135
133
136
* ` asSuccess($api_code) ` : Returns Builder instance configured to return success indicating message.
134
- You can ommit ` $api_code ` to fall back to default code for ` OK ` ).
137
+ You can ommit ` $api_code ` to fall back to default code for ` OK ` ( ` ApiCodes::OK() ` ).
135
138
* ` asError($api_code) ` : Returns Builder instance configured to produce error indicating response. ` $api_code `
136
139
must not equal to value indicating ` OK ` (` ApiCodes::OK() ` ).
137
140
@@ -298,7 +301,7 @@ $data = [
298
301
Where ` <VERSION> ` string consists of ` MAJOR ` and ` MINOR ` release numbers. For
299
302
example if current relase is 6.4.13, you need to invoke:
300
303
301
- composer require marcin-orlowski/laravel-api-response-builder:6.3
304
+ composer require marcin-orlowski/laravel-api-response-builder:6.4
302
305
303
306
which will add the dependency at the release 6.3 + all the bugfixing releses
304
307
(` 6.3.* ` ) but won't automatically pull 6.4 even if available, unless
0 commit comments