Update clear cache all add command to clear session files also
This commit is contained in:
@@ -4,7 +4,7 @@ namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ClearAllCaches extends Command
|
||||
class ClearCachesAll extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
@@ -34,6 +34,7 @@ class ClearAllCaches extends Command
|
||||
$this->call('optimize:clear');
|
||||
$this->call('package:discover');
|
||||
$this->call('queue:clear');
|
||||
$this->call('clear-sessions');
|
||||
|
||||
$this->info("All caches have been cleared.");;
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use File;
|
||||
|
||||
class ClearSessions extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'clear-sessions';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Clear all session files';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$files = File::files(storage_path('framework/sessions'));
|
||||
|
||||
foreach ($files as $file) {
|
||||
File::delete($file);
|
||||
}
|
||||
|
||||
$this->info('Session files cleared successfully.');
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user