PHPackages                             litalico-engineering/eg-r2 - 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. litalico-engineering/eg-r2

ActiveLibrary[API Development](/categories/api)

litalico-engineering/eg-r2
==========================

Easy request validation and route generation from open API specifications (for Laravel)

1.4.2(2mo ago)1112.5k↓40.3%2[1 PRs](https://github.com/litalico-engineering/eg-r2/pulls)MITPHPPHP ^8.2|^8.3|^8.4|^8.5CI passing

Since Feb 5Pushed 2mo ago6 watchersCompare

[ Source](https://github.com/litalico-engineering/eg-r2)[ Packagist](https://packagist.org/packages/litalico-engineering/eg-r2)[ RSS](/packages/litalico-engineering-eg-r2/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (24)Versions (19)Used By (0)

[![test passed](https://github.com/litalico-engineering/eg-r2/actions/workflows/test.yml/badge.svg)](https://github.com/litalico-engineering/eg-r2/actions/workflows/test.yml/badge.svg)

Easy request validation and route generation from open API specifications (for Laravel)
=======================================================================================

[](#easy-request-validation-and-route-generation-from-open-api-specifications-for-laravel)

`eg-r2` means `eg` in the sense that it makes `Easy(eg)` the `two R(r2)`s: `Request validation` and `Routing generation`.

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

[](#installation)

1. Install via Composer

    ```
    composer require litalico-engineering/eg-r2
    ```
2. (Optional) Publish configuration file

    ```
    php artisan vendor:publish --provider="Litalico\EgR2\Providers\EgR2ServiceProvider" --tag=eg-r2-config
    ```

    This creates `config/eg_r2.php` for customization. If not published, default configuration will be used.
3. (Optional) Publish language files

    ```
    php artisan vendor:publish --provider="Litalico\EgR2\Providers\EgR2ServiceProvider" --tag=eg-r2-lang
    ```

    This copies language files to `resources/lang/vendor/eg_r2/` for customization. Default language files (Japanese and English) are automatically loaded from the package.

Usage
-----

[](#usage)

### Basic Setup

[](#basic-setup)

1. Add [swagger-php](https://github.com/zircote/swagger-php) attributes to the classes (Controller and FormRequest) corresponding to each API to create an OpenAPI document.
    see.

Important

No need to define routing for Controller methods

2. Configure the `config/eg_r2.php` (if you published it in step 2 of Installation)
    Describe the namespace of the Controller that describes the OpenAPI Attribute.
    If you didn't publish the config file, you can create it manually at `config/eg_r2.php`:

    ```
