Skip to content

Instantly share code, notes, and snippets.

@keithgreer
Last active December 23, 2021 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keithgreer/1121f6a08ad6033272dd21274159eac8 to your computer and use it in GitHub Desktop.
Save keithgreer/1121f6a08ad6033272dd21274159eac8 to your computer and use it in GitHub Desktop.
<?php
use Magento\Framework\App\Bootstrap;
include('app/bootstrap.php'); // Update as required, this line will work if placed in the Magento Root Directory
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
?><div style='top:45%; position:absolute; width:75%; text-align:center; color:#666; font-weight:bold; font-size:1.8em; '><?php
try{
$_cacheTypeList = $objectManager->create('Magento\Framework\App\Cache\TypeListInterface');
$_cacheFrontendPool = $objectManager->create('Magento\Framework\App\Cache\Frontend\Pool');
$types = array('config','layout','block_html','collections','reflection','db_ddl','eav','config_integration','config_integration_api','full_page','translate','config_webservice');
foreach ($types as $type) {
$_cacheTypeList->cleanType($type);
}
foreach ($_cacheFrontendPool as $cacheFrontend) {
$cacheFrontend->getBackend()->clean();
}
?><span style='color:green'>&#9679; Success. </span> The cache has been cleared. <?php
}catch(Exception $e){
?><span style='color:red'>&#9679; Error. </span><?php
echo $msg = 'Error : '.$e->getMessage();die();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment