PHPackages                             alirah/laravel-rest - 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. alirah/laravel-rest

ActiveLibrary[API Development](/categories/api)

alirah/laravel-rest
===================

This package used for building Laravel RESTFUL API much easier.

v1.0.0(4y ago)614MITPHPPHP &gt;=7.1

Since Feb 22Pushed 4y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Laravel Rest
============

[](#laravel-rest)

This is a Laravel Package to build RESTFUL API much easier. This package supports `Laravel 5.8+`.

> With this package you can build all the things needed for RESTFUL API with only one command. Such as Controller, Resource, Request, Model, Migration, Seeder, Factory, Route, Test and swagger. Moreover, you can delete it as well.

---

List of contents
================

[](#list-of-contents)

- [Laravel Rest](#Laravel-Rest)
- [List of contents](#list-of-contents)
- [Install](#Install)
- [Configure](#Configure)
- [Swagger](#Swagger)
- [Testing](#Testing)
- [How to use](#How-to-use)
    - [Create](#Create)
    - [Delete](#Delete)
    - [Versioning](#Versioning)
        - [Versioning Create](#versioning-create)
        - [Versioning Delete](#versioning-delete)
    - [Rest Facade](#rest-facade)
    - [Example](#example)
- [Security](#security)
- [Credits](#credits)
- [License](#license)

---

Install
-------

[](#install)

Via Composer

```
$ composer require alirah/laravel-rest
```

Configure
---------

[](#configure)

If you are using `Laravel 5.5` or higher than you don't need to add the provider and alias. (Skip to b)

a. In your `config/app.php` file add these two lines.

```
// In your providers array.
'providers' => [
    ...
    Alirah\LaravelRest\Provider\LaravelRestServiceProvider::class,
],

// In your aliases array.
'aliases' => [
    ...
    'Rest' => Alirah\LaravelRest\Facade\Rest::class,
],
```

b. then run the command in below to publish `config/laravel-rest.php` file in your config directory :

```
$ php artisan vendor:publish --provider="Alirah\LaravelRest\Provider\LaravelRestServiceProvider" --tag="config"
```

After running the command , you can set your desired configuration.

---

```
    // to use swagger you have to install darkaonline/l5-swagger
    'swagger' => false,
    'swagger_route_prefix' => 'api',

    'model' => true,
    'migration' => true,
    'factory_seeder' => true,
    'test' => true,

    'route' => true,
    // file in the routes' folder
    // if you have another folder in routes use this pattern: v1/api.php
    'route_path' => 'api.php'
```

---

Swagger
-------

[](#swagger)

In order to use Swagger, you need to follow these steps:

a. Run this command:

```
$ composer require darkaonline/l5-swagger
```

b. Next, publish config/views from Service Provider:

```
$ php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider"
```

c. Copy the code in below then paste it to the top of the Controller class in App\\Http\\Controller\\Controller :

```
/**
 * @OA\Info (
 *      title="Laravel Rest Swagger",
 *      version="1.0.0",
 * )
 *
 * @OA\Get(
 *     path="/",
 *     description="Home page",
 *     @OA\Response(response="200", description="Home Page")
 * )
 */
```

At the end, your controller must be like this:

```
