File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php namespace App \Console \Commands ;
2
+
3
+ use Illuminate \Console \Command ;
4
+ use Illuminate \Filesystem \Filesystem ;
5
+
6
+ class ClearPageCache extends Command
7
+ {
8
+ /**
9
+ * The name of the console command.
10
+ *
11
+ * @var string
12
+ */
13
+ protected $ name = 'docs:clear-cache ' ;
14
+
15
+ /**
16
+ * The console command description.
17
+ *
18
+ * @var string
19
+ */
20
+ protected $ description = 'Clears the page cache. ' ;
21
+
22
+ /**
23
+ * Execute the console command.
24
+ *
25
+ * @return mixed
26
+ */
27
+ public function handle ()
28
+ {
29
+ $ path = public_path ('page-cache ' );
30
+
31
+ if ($ this ->clearDirectory ($ path )) {
32
+ $ this ->info ("Page cache directory cleared at {$ path }. " );
33
+ } else {
34
+ $ this ->warn ("Page cache directory not cleared at {$ path }. " );
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Clear all contents of the given directory recursively.
40
+ *
41
+ * @param string $path
42
+ * @return bool
43
+ */
44
+ protected function clearDirectory ($ path )
45
+ {
46
+ return $ this ->laravel ->make (Filesystem::class)->deleteDirectory ($ path , true );
47
+ }
48
+ }
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ class Kernel extends ConsoleKernel
11
11
* @var array
12
12
*/
13
13
protected $ commands = [
14
+ Commands \ClearPageCache::class,
14
15
Commands \IndexDocumentation::class,
15
16
];
16
17
You can’t perform that action at this time.
0 commit comments