appstract / laravel-response-macros
Extra Response Macro's for Laravel
Installs: 1 415
Dependents: 0
Suggesters: 0
Security: 0
Stars: 33
Watchers: 5
Forks: 4
Open Issues: 0
Requires
- php: >=5.6
- laravel/framework: >=5.4
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is not auto-updated.
Last update: 2024-11-10 05:14:10 UTC
README
This package is a collection of custom response macros that you can re-use in a variety of your routes and controllers.
Installation
You can install the package via composer:
composer require appstract/laravel-response-macros
Usage
Message
return response()->message('hello world!', 200);
Result
{ "message": "hello world!" }
With the Http Status Code: 200
Error
return response()->error('Something went wrong', $statuscode = 400);
Result
{ "message": "Something went wrong" }
With the Http Status Code: 400
Success
return response()->success(['some' => 'data'], $statuscode = 200);
Result
{ "data": {"some": "data"} }
With the Http Status Code: 200
Creates a (downloadable) PDF response from PDF contents.
return response()->pdf($pdfData, 'filename.pdf', $download = false);
Testing
$ composer test
Contributing
Contributions are welcome, thanks to y'all :)
About Appstract
Appstract is a small team from The Netherlands. We create (open source) tools for webdevelopment and write about related subjects on Medium. You can follow us on Twitter, buy us a beer or support us on Patreon.
License
The MIT License (MIT). Please see License File for more information.