PHP code example of teners / laravel-key-case

1. Go to this page and download the library: Download teners/laravel-key-case library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

teners / laravel-key-case example snippets


    ->withMiddleware(function (Middleware $middleware) {
        $middleware->api(append: [
            \Teners\LaravelKeyCase\Http\Middleware\TransformResponseMiddleware:class,
        ]);
    })

    // Or to use on individual routes
    
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->alias([
            'convert-response-key' => \Teners\LaravelKeyCase\Http\Middleware\TransformResponseMiddleware:class,
        ]);
    })

    protected $middlewareGroups = [
        'web' => [
            ...
        ],

        'api' => [
            ...
            TransformResponseMiddleware::class,
        ],
    ];

    // Or to use on individual routes

    // Laravel 9 uses $routeMiddleware = [
    //protected $routeMiddleware = [
    // Laravel 10+ uses $middlewareAliases = [
    protected $middlewareAliases = [
        // ...
        'convert-response-key' => \Teners\LaravelKeyCase\Http\Middleware\TransformResponseMiddleware:class,
    ];

return [
    // Other configuration options...

    'ignore' => [
        // Common routes to ignore for both request and response transformation
    ],

    'ignoreRequest' => [
        // List of routes to ignore for request transformation
    ],

    'ignoreResponse' => [
        // List of routes to ignore for response transformation
    ],
];
bash
php artisan vendor:publish --provider="Teners\LaravelKeyCase\LaravelKeyCaseServiceProvider" --tag="key-case-config"