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.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// extend.php
use Acpl\FlarumLSCache\Utility\LSCachePurger;
use Flarum\Extend;
return [
// ... your current extenders
(new Extend\Conditional)
->whenExtensionEnabled('acpl-lscache', function () {
LSCachePurger::$resourcesSupportedByEvent[] = 'example';
return [
(new Extend\Event)->listen(ExampleUpdated::class, ExampleUpdatedListener::class),
];
}),
];
// ExampleUpdatedListener.php
use Acpl\FlarumLSCache\Listener\AbstractCachePurgeListener;
/** @extends AbstractCachePurgeListener<ExampleUpdated> */
class ExampleUpdatedListener extends AbstractCachePurgeListener
{
protected function addPurgeData(object $event): void
{
$this->purger->addPurgeTags([
'examples',
"example_{$event->example->id}",
]);
}
}
// extend.php
use Acpl\FlarumLSCache\Utility\LSCachePurger;
use Flarum\Extend;
return [
// ... your current extenders
(new Extend\Conditional)
->whenExtensionEnabled('acpl-lscache', function () {
LSCachePurger::$resourcesSupportedByEvent[] = 'example';
return [
(new Extend\Event)->subscribe(ExampleEventSubscriber::class),
];
}),
];
// ExampleEventSubscriber.php
use Acpl\FlarumLSCache\Listener\AbstractCachePurgeSubscriber;
use Illuminate\Contracts\Events\Dispatcher;
class ExampleEventSubscriber extends AbstractCachePurgeSubscriber
{
public function subscribe(Dispatcher $events): void
{
$this->addPurgeListener($events, ExampleUpdated::class, $this->handleExampleUpdated(...));
// ... rest of listeners
}
public function handleExampleUpdated(ExampleUpdated $event): void
{
$this->purger->addPurgeTags([
'examples',
"example_{$event->example->id}",
]);
}
// ... rest of methods
}
sh
composer update acpl/flarum-lscache
php flarum migrate
php flarum cache:clear
sh
php flarum lscache:clear
php flarum lscache:clear --path=/tags --path=/d/1-test
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.