PHP code example of bagisto / bagisto-varnish

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

    

bagisto / bagisto-varnish example snippets




use Webkul\Varnish\Providers\VarnishServiceProvider;
// ...other Webkul providers

return [
    // ...other Webkul providers

    VarnishServiceProvider::class,   // ← must be LAST
];

use Webkul\Varnish\Facades\VarnishCache;

VarnishCache::forget('/some-path');       // one page, every variant
VarnishCache::forget(['/a', '/b']);       // several
VarnishCache::flush();                    // everything

return [
    'esi' => [
        'views' => [
            'customer-desktop-dropdown' => 'varnish::shop.components.layouts.header.desktop.customer-dropdown',
        ],
    ],
];

Route::get('/', [HomeController::class, 'index'])
    ->name('shop.home.index')
    ->middleware('cache.response');
bash
php artisan vendor:publish --provider="Webkul\Varnish\Providers\VarnishServiceProvider"
php artisan optimize:clear
bash
   sudo cp default.vcl /etc/varnish/default.vcl
   sudo varnishd -C -f /etc/varnish/default.vcl > /dev/null && echo "VCL compiles"
   sudo systemctl reload varnish
   
bash
php artisan varnish:flush            #