Cache Cleaner

Triggering cache clean from custom extension

1 year 11 months ago #64886

keep's Avatar keep

Is there a way to trigger cache clean from my custom extension via PHP?

1 year 11 months ago #64896

Peter van Westen's Avatar Peter van Westen Admin

Try:

require_once JPATH_LIBRARIES . '/regularlabs/helpers//parameters.php';
$params = RLParameters::getInstance()->getPluginParams('cachecleaner');

require_once JPATH_PLUGINS . '/system/cachecleaner/helper.php';
$cachecleaner = new PlgSystemCacheCleanerHelper($params);

$cachecleaner->clean();

1 year 11 months ago #65044

keep's Avatar keep

Peter van Westen wrote:

Try:
require_once JPATH_LIBRARIES . '/regularlabs/helpers//parameters.php';
$params = RLParameters::getInstance()->getPluginParams('cachecleaner');

require_once JPATH_PLUGINS . '/system/cachecleaner/helper.php';
$cachecleaner = new PlgSystemCacheCleanerHelper($params);

$cachecleaner->clean();

great, thanks

1 year 3 weeks ago #74983

Toni56's Avatar Toni56

If I'm right it has been changed since your reply. Could you please update it?

1 year 3 weeks ago #74985

Peter van Westen's Avatar Peter van Westen Admin

Please try the latest development version from:
www.regularlabs.com/development-releases

Then you can do:

require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
require_once JPATH_PLUGINS . '/system/cachecleaner/vendor/autoload.php';

$result = \RegularLabs\Plugin\System\CacheCleaner\Cache::purge();

The $result will contain an object with an error and message value.

1 year 3 weeks ago #75005

Toni56's Avatar Toni56

Peter van Westen wrote:

Please try the latest development version from:
www.regularlabs.com/development-releases

Then you can do:
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
require_once JPATH_PLUGINS . '/system/cachecleaner/vendor/autoload.php';

$result = \RegularLabs\Plugin\System\CacheCleaner\Cache::purge();

The $result will contain an object with an error and message value.

I can't find Cache Cleaner there :)

1 year 3 weeks ago #75010

Peter van Westen's Avatar Peter van Westen Admin

Sorry about that. Should be there now...
www.regularlabs.com/development-releases

11 months 2 weeks ago #76014

Toni56's Avatar Toni56

I tried to use it from a CLI script but got this message:
Error displaying the error page: Application Instantiation Error: Class 'RegularLabs\Library\Parameters' not found

11 months 2 weeks ago #76016

Peter van Westen's Avatar Peter van Westen Admin

Sorry,you also need to autoload the Regular Labs Library:

require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';

I have updated the code above too.