PHPackages                             sajadsdi/laravel-rest-response - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. sajadsdi/laravel-rest-response

ActiveLaravel-library[API Development](/categories/api)

sajadsdi/laravel-rest-response
==============================

Easy return clean response with RESTful api stracture

1.0.4(1y ago)4531MITPHPPHP ^8.0

Since Dec 3Pushed 1y ago2 watchersCompare

[ Source](https://github.com/sajadsdi/laravel-rest-response)[ Packagist](https://packagist.org/packages/sajadsdi/laravel-rest-response)[ RSS](/packages/sajadsdi-laravel-rest-response/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (2)Versions (7)Used By (1)

[![Laravel REST Response](https://camo.githubusercontent.com/c26882728537ad9da4e215a975de20d76c490e0e923c6908d41d58adef5948d1/68747470733a2f2f73616a61647364692e6769746875622e696f2f696d616765732f4c61726176656c2d5245535466756c2d526573706f6e73652e6a7067)](https://camo.githubusercontent.com/c26882728537ad9da4e215a975de20d76c490e0e923c6908d41d58adef5948d1/68747470733a2f2f73616a61647364692e6769746875622e696f2f696d616765732f4c61726176656c2d5245535466756c2d526573706f6e73652e6a7067)

Laravel REST Response
=====================

[](#laravel-rest-response)

a PHP package that simplifies the generation of clean and consistent responses for RESTful APIs in Laravel applications.

Features
--------

[](#features)

- **Versioning Support:** The package allows you to include API version information in your responses.
- **HTTP Status Codes:** Easily set and customize HTTP status codes for different response scenarios.
- **Common Response Methods:** Predefined methods for common responses such as create, update, delete, not found, forbidden, unauthorized, and bad request.
- **Easy Integration:** Seamlessly integrate the package with your Laravel controllers for quick and standardized API responses.
- **Base Request:** Use `BaseRequest` for all request classes to integrate validation or authorization response errors with the package’s response.
- **CRUD Operations** Use `CrudApi` trait to provide a standard way of handling CRUD operations.

Installation
------------

[](#installation)

You can install this library using Composer. If you haven't already set up Composer for your project, you can do so by following the [official Composer installation guide](https://getcomposer.org/doc/00-intro.md).

Once Composer is installed, run the following command to install Laravel REST Response:

```
composer require sajadsdi/laravel-rest-response
```

Usage
-----

[](#usage)

It is recommended to extend the `RestController` class in your base controller, to allowing all controllers that inherit from it to have access to the RESTful methods. This approach provides a convenient way to handle API responses consistently across your application.

### Extending in Base Controller

[](#extending-in-base-controller)

In the Laravel application, there is a base controller by default, which you can find at the address below.

```
App\Http\Controllers\Controller
```

open Controller.php or your custom base controller.

```
