1. Go to this page and download the library: Download acpl/flarum-lscache library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
acpl / flarum-lscache example snippets
(new Extend\Routes('api'))
->get('/examples', 'examples.index', ExamplesListController::class)
->post('/examples', 'examples.create', ExamplesCreateController::class)
// and so on
// 💡 resource name should be in singular form
\ACPL\FlarumLSCache\Utility\LSCachePurger::$resourcesSupportedByEvent[] = 'example'return [
// ... your current extenders
];
// extend.phpuseFlarum\Extend;
return [
// ... your current extenders
(new Extend\Conditional)
->whenExtensionEnabled('acpl-lscache', [
(new Extend\Event)->listen(ExampleUpdated::class, ExampleUpdatedListener::class)
]),
];
// ExampleUpdatedListener.phpuseACPL\FlarumLSCache\Listener\AbstractCachePurgeListener;
classExampleUpdatedListenerextendsAbstractCachePurgeListener{
/** @param ExampleUpdated $event */protectedfunctionaddPurgeData($event): void{
// Purge cache tag$this->purger->addPurgeTag('examples');
// or purge multiple cache tags$this->purger->addPurgeTags([
'examples',
"examples_{$event->example->id}"
]);
// Purge a single path$this->purger->addPurgePath('/examples');
// or purge multiple paths$this->purger->addPurgePaths([
'/examples',
"/examples_{$event->example->id}",
]);
}
}
// extend.phpuseFlarum\Extend;
return [
// ... your current extenders
(new Extend\Conditional)
->whenExtensionEnabled('acpl-lscache', [
(new Extend\Event)->subscribe(ExampleEventSubscriber::class),
]),
];