Skip to content

MRizki28/MRizki28-ApiResponse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

simple package to help you in handling json responses

Requirements

  • PHP ^8.2

Installation

composer require mrizki28/handler-api-response

Example

<?php

namespace App\Http\Controller;

use App\Http\Controllers\Controller;
use MRizki28\ApiResponse\ApiResponse;
use App\Models\User;

class ExampleController extends Controller
{
    public function getAllUser()
    {
        $data = User::all();
        return ApiResponse::success($data, 'success get all user', 200);
    }
}

Available methods

ApiResponse.success($data , $message, $code)

$data array $message string $code int default return 200

ApiResponse.notFound($message, $code)

$message string $code int default return 404

ApiResponse.error($th, $message, $code)

$message string $th \Throwable $code int default return 500

ApiResponse.unauthorize()

Contribution

Any ideas are welcome. Feel free to submit any issues or pull requests.

License

The MIT License (MIT). Please see License File for more information.

About

simple package to help you in handling json responses

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages