PHP code example of tinigin / laravel-etag

1. Go to this page and download the library: Download tinigin/laravel-etag 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/ */

    

tinigin / laravel-etag example snippets


// in bootstrap/app.php

->withMiddleware(function (Middleware $middleware) {
    $middleware->web(append: [
        \Tinigin\ETag\Middleware\ETagHandling::class,
    ]);
})


 
namespace App\Http\Controllers;
 
use App\Http\Controllers\Controller;
use ETag;
 
class PostController extends Controller
{
    public function show($id)
    {
        $post = \App\Models\Post::findOrFail($id);

        ETag::set($post->getKey());
        
        return view('posts.show', ['post' => $post]);
    }
}
bash
php artisan vendor:publish --tag="etag-config"