Skip to content

Commit 960ac4e

Browse files
committed
Add OpCache reset API endpoint and webhook integration, refactor deployment tasks, update dependencies.
1 parent e5a59b1 commit 960ac4e

5 files changed

Lines changed: 223 additions & 203 deletions

File tree

app/Http/Controllers/Api/IndexController.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
/**
2424
* Class IndexController
2525
*/
26-
class IndexController
26+
class IndexController extends ApiController
2727
{
2828
/**
2929
* @return string
@@ -32,4 +32,28 @@ public function index()
3232
{
3333
return \View::make('front.api-index');
3434
}
35+
36+
/**
37+
* Reset OPcache
38+
*
39+
* @return \Illuminate\Http\Response
40+
*/
41+
public function resetOpcache(string $token)
42+
{
43+
$validToken = config('app.opcache_webhook_token', null);
44+
45+
if (empty($validToken) || $token !== $validToken) {
46+
return $this->errorUnauthorized('Invalid reset token.');
47+
}
48+
49+
if (function_exists('opcache_reset')) {
50+
if (opcache_reset()) {
51+
return $this->respondWithArray(['message' => 'OPcache reset successful']);
52+
}
53+
54+
return $this->errorInternalError('OPcache reset failed');
55+
}
56+
57+
return $this->errorInternalError('OPcache extension not loaded');
58+
}
3559
}

0 commit comments

Comments
 (0)