Download the PHP package youngmayor/app-response without Composer
On this page you can find all versions of the php package youngmayor/app-response. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download youngmayor/app-response
More information about youngmayor/app-response
Files in youngmayor/app-response
Package app-response
Short Description A laravel package for providing unified easy to use response to our laravel applicatons
License MIT
Homepage https://github.com/youngmayor/laravel-app-response
Informations about the package app-response
Laravel App Response
This is a simple laravel package for providing a unified response for our application.
Installation
You can install the package via composer:
Usage
The package uses auto discovery hence if you use Laravel 5.5 or above, installing the package automatically registers it in your application.
However, if you use Laravel 5.4 or below you will need to add the below snipet to your config/app.php
to register the Service Provider and alias
The package can now be added to our controller actions using one of the methdos below
-
Injecting the API response helper
-
Injecting the Web response helper
-
Injecting the automatic response helper
-
Using the package facade
- Using the helper function
Response Types
The package provides two forms of responses, Web and API. It also provides an Auto responder which essentially responds as API if Accept: application/json
header exists and responds as Web if the header is missing.
API Response
This returns a JSON response
Example
Web Response
This renders a web page as the response. An example is attached below
Web response can be completed turned off by making setting the
app-response.render-web-as-view
configuration to false. The configuration file can be published using the below command
The web response can also be customised. To publish the views run the below code on the root of your application terminal
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Meyoron Aghogho
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.