Skip to content

Commit 2acf17a

Browse files
committed
Initial release
0 parents  commit 2acf17a

File tree

9 files changed

+180
-0
lines changed

9 files changed

+180
-0
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Ask a Question
4+
url: https://github.com/vursion/laravel-opcache/discussions/new?category=q-a
5+
about: Ask the community for help
6+
- name: Feature Request
7+
url: https://github.com/vursion/laravel-opcache/discussions/new?category=ideas
8+
about: Share ideas for new features
9+
- name: Bug Report
10+
url: https://github.com/vursion/laravel-opcache/issues/new
11+
about: Report a reproducable bug

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
composer.lock
2+
vendor

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
All notable changes to `laravel-opcache` will be documented in this file
4+
5+
## 1.0.0 - 2022-01-31
6+
7+
- initial release.

LICENSE.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2020-2022 vursion
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Laravel OPCache
2+
3+
[![Latest Version on Packagist](https://img.shields.io/packagist/v/vursion/laravel-opcache.svg?style=flat-square)](https://packagist.org/packages/vursion/laravel-opcache)
4+
[![Total Downloads](https://img.shields.io/packagist/dt/vursion/laravel-opcache.svg?style=flat-square)](https://packagist.org/packages/vursion/laravel-opcache)
5+
6+
## Installation
7+
8+
You can install the package via composer:
9+
10+
```bash
11+
composer require vursion/laravel-opcache
12+
```
13+
14+
***No need to register the service provider if you're using Laravel >= 5.5.
15+
The package will automatically register itself.***
16+
Once the package is installed, you can register the service provider in `config/app.php` in the providers array:
17+
18+
```php
19+
'providers' => [
20+
...
21+
Vursion\LaravelOPCache\OPCacheServiceProvider::class
22+
],
23+
```
24+
25+
## Usage
26+
27+
Clear/Reset OPCache
28+
29+
```bash
30+
php artisan opcache:reset
31+
```
32+
33+
## Changelog
34+
35+
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
36+
37+
## Security
38+
39+
If you discover any security related issues, please email support@vursion.io instead of using the issue tracker.
40+
41+
## Credits
42+
43+
- [Jochen Sengier](https://github.com/celcius-jochen)
44+
45+
## License
46+
47+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

composer.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "vursion/laravel-opcache",
3+
"description": "laravel-opcache",
4+
"keywords": [
5+
"vursion",
6+
"laravel",
7+
"opcache"
8+
],
9+
"homepage": "https://github.com/vursion/laravel-opcache",
10+
"license": "MIT",
11+
"type": "library",
12+
"authors": [
13+
{
14+
"name": "Jochen Sengier",
15+
"email": "support@vursion.io",
16+
"role": "Developer"
17+
}
18+
],
19+
"require": {
20+
"php": "^5.4 || ^7.0 || ^7.1 || ^7.2 || ^7.3 || ^7.4 || ^8.0 || ^8.1",
21+
"guzzlehttp/guzzle": "^5.0 || ^6.0 || ^7.0",
22+
},
23+
"autoload": {
24+
"psr-4": {
25+
"Vursion\\LaravelOPCache\\": "src"
26+
}
27+
},
28+
"config": {
29+
"sort-packages": true
30+
},
31+
"extra": {
32+
"laravel": {
33+
"providers": [
34+
"Vursion\\LaravelOPCache\\OPCacheServiceProvider"
35+
]
36+
}
37+
}
38+
}

routes/web.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
Route::get('opcache/reset', function () {
4+
if (function_exists('opcache_reset')) {
5+
return response()->json(opcache_reset());
6+
}
7+
})->name('opcache-reset')->middleware((version_compare(app()->version(), '5.6.12') >= 0) ? 'signed' : null);

src/OPCacheResetCommand.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Vursion\LaravelOPCache;
4+
5+
use GuzzleHttp\Client;
6+
use Illuminate\Console\Command;
7+
8+
class OPCacheResetCommand extends Command
9+
{
10+
protected $signature = 'opcache:reset';
11+
12+
protected $description = 'Reset OPCache';
13+
14+
public function handle()
15+
{
16+
$route = (version_compare(app()->version(), '5.6.12') >= 0) ? \Illuminate\Support\Facades\URL::signedRoute('opcache-reset') : route('opcache-reset');
17+
18+
$response = new Client([
19+
'http_errors' => false,
20+
'verify' => false,
21+
])->get($route);
22+
23+
if ($response->getStatusCode() === 200) {
24+
return json_decode($response->getBody()->getContents());
25+
}
26+
}
27+
}

src/OPCacheServiceProvider.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Vursion\LaravelOPCache;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
use Vursion\LaravelOPCache\OPCacheResetCommand;
7+
8+
class OPCacheServiceProvider extends ServiceProvider
9+
{
10+
public function boot()
11+
{
12+
$this->loadRoutesFrom(__DIR__.'/../routes/web.php');
13+
}
14+
15+
public function register()
16+
{
17+
$this->commands([
18+
OPCacheResetCommand::class,
19+
]);
20+
}
21+
}

0 commit comments

Comments
 (0)