Skip to content

ak4bento/message

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Message JSON Response And HTML Response (Commingsoon) Laravel 5

FOSSA Status

A minimal package for JSON Response API and HTML Response (Commingsoon) to clients, Laravel.

Getting Started

Install the package via composer.

Download package dengan composer

composer require akilsagitarius/message

or

{
	"require": {
		"akilsagitarius/message" : "dev-master"
	}
}

Register the service provider.

This package makes use of Laravel's auto-discovery of service providers. If you are an using earlier version of Laravel (< 5.4) you will need to manually register the service provider.

Add akilsagitarius\message\MessageServiceProvider::class to the providers array in config/app.php.

example

'providers' => [
	....
	
	akilsagitarius\message\MessageServiceProvider::class,
]

Register the service provider.

Now, publish the configuration code response to your provider

php artisan vendor:publish --tag=public --force

Usage

Basic

NOTE: The response code returned in the body payload will be set as the actual HTTP header response code as well.

Regular Responses

This is simple response

Route::get('/message', function () {
    $reuslt = Message::success(200)->get();
    return $reuslt;
});

Will result in the following structured result:

{
    code: 200,
    result: "Success",
    message: "OK"
}

Secondary Responses

This is response with result your send

Route::get('/mess', function () {
    $array = array(
        'first' => 'This is first data',
        'second' => 'This is second data',
    );
    $reuslt = Message::success(200)->payload($array)->get();
    return $reuslt;
});

Will result in the following structured result:

{
    code: 200,
    result: "Informational",
    message: "OK",
    payload: {
        first: "This is first data",
        second: "This is second data"
    }
}

Authors

*Muhammad Akil - Initial work - Akill

License

FOSSA Status

FOSSA Status

Acknowledgments

  • Hat tip to anyone whose code was used
  • Inspiration
  • etc

About

This is a response message with code

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages