PHP code example of thoughtco / statamic-cache-tracker

1. Go to this page and download the library: Download thoughtco/statamic-cache-tracker 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/ */

    

thoughtco / statamic-cache-tracker example snippets


Tracker::addAdditionalTracker(function ($tracker, $next) {
    // run your logic, for example in an augmentation hook
    // then call:
    $tracker->addContentTag('your-tag-here');

    return $next($tracker);
});

class AdditionalTrackerClass {
    public function __invoke($tracker, $next) {
        $tracker->addContentTag('additional::tag');
    }
}

Tracker::addAdditionalTracker(AdditionalTrackerClass::class);

Thoughtco\StatamicCacheTracker\Events\TrackContentTags::dispatch(['additional::tag']);

$tags = ['one', 'two', 'three'];
Tracker::invalidate($tags);
bash
php artisan vendor:publish --tag=statamic-cache-tracker-config