Skip to content

Commit fa30e43

Browse files
committed
feat(log): replace arcanedev/log-viewer with custom implementation for Laravel 12 compatibility
- Replace the arcanedev/log-viewer package with a custom log viewer implementation - Add support for Laravel 12 - Update GitHub workflow to test against both Laravel 11 and 12 - Simplify logs interface with datatable and better UI - Update PHP version variable in Makefile for better compatibility - Remove outdated phpcs rules - Update documentation to reflect changes in log visualization - Update menu test to match new logs menu structure
1 parent f49224a commit fa30e43

34 files changed

+657
-515
lines changed

.github/workflows/tests.yml

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,70 @@
11
name: tests
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
48

59
jobs:
6-
tests:
10+
tests-laravel-11:
711
runs-on: ubuntu-latest
812
strategy:
913
fail-fast: false
1014
matrix:
1115
include:
1216
- php: 8.2
1317
laravel: '^11.0'
14-
15-
name: PHP ${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.laravel }}
16-
18+
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}
1719
steps:
18-
- name: Checkout code
19-
uses: actions/checkout@v2
20-
20+
- uses: actions/checkout@v4
21+
- name: Validate composer.json and composer.lock
22+
run: composer validate --strict
2123
- name: Cache dependencies
22-
uses: actions/cache@v1
24+
uses: actions/cache@v3
2325
with:
24-
path: ~/.composer/cache/files
25-
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
26-
26+
path: vendor
27+
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.lock') }}
2728
- name: Setup PHP
2829
uses: shivammathur/setup-php@v2
2930
with:
3031
php-version: ${{ matrix.php }}
31-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd
32+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, xdebug
3233
coverage: none
33-
3434
- name: Install dependencies
3535
run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress --with laravel/framework:${{ matrix.laravel }}
36-
3736
- name: Execute code sniffing
3837
run: vendor/bin/phpcs
39-
4038
- name: Execute tests
4139
run: vendor/bin/phpunit
40+
41+
tests-laravel-12:
42+
runs-on: ubuntu-latest
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
include:
47+
- php: 8.2
48+
laravel: '^12.0'
49+
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}
50+
steps:
51+
- uses: actions/checkout@v4
52+
- name: Validate composer.json and composer.lock
53+
run: composer validate --strict
54+
- name: Cache dependencies
55+
uses: actions/cache@v3
56+
with:
57+
path: vendor
58+
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.lock') }}
59+
- name: Setup PHP
60+
uses: shivammathur/setup-php@v2
61+
with:
62+
php-version: ${{ matrix.php }}
63+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, xdebug
64+
coverage: none
65+
- name: Install dependencies
66+
run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress --with laravel/framework:${{ matrix.laravel }}
67+
- name: Execute code sniffing
68+
run: vendor/bin/phpcs
69+
- name: Execute tests
70+
run: vendor/bin/phpunit

Makefile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
.PHONY:help cs csfix test testcoverage testcoveragehtml clean
22
.DEFAULT_GOAL=help
33

4+
PHP?=php8.2
5+
46
help:
57
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
68

79
composer.phar:
8-
@curl -sS https://getcomposer.org/installer | php -- --filename=composer.phar
10+
@curl -sS https://getcomposer.org/installer | $(PHP) -- --filename=composer.phar
911
@chmod +x composer.phar
1012

1113
vendor: composer.phar composer.json
12-
@./composer.phar install --prefer-source --no-interaction --optimize-autoloader
14+
@$(PHP) composer.phar install --no-interaction --optimize-autoloader
1315

1416
cs: vendor ## Check for coding standards
15-
@php vendor/bin/phpcs
17+
@$(PHP) vendor/bin/phpcs
1618

1719
csfix: vendor ## Check and fix for coding standards
18-
@php vendor/bin/phpcbf
20+
@$(PHP) vendor/bin/phpcbf
1921

2022
test: vendor phpunit.xml ## Unit testing
21-
@php vendor/bin/phpunit --stop-on-failure
23+
@$(PHP) vendor/bin/phpunit --stop-on-failure
2224

2325
testcoverage: composer.phar vendor phpunit.xml ## Unit testing with code coverage
24-
@XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text
26+
@XDEBUG_MODE=coverage $(PHP) vendor/bin/phpunit --coverage-text
2527

2628
testcoveragehtml: composer.phar vendor phpunit.xml ## Unit testing with code coverage in HTML
27-
@XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-html coverage
29+
@XDEBUG_MODE=coverage $(PHP) vendor/bin/phpunit --coverage-html coverage
2830

2931
clean: ## Remove files needed for tests
30-
@rm -rf composer.phar composer.lock vendor testbench coverage .phpunit.result.cache .phpunit.cache
32+
@rm -rf composer.phar composer.lock vendor testbench coverage .phpunit.result.cache .phpunit.cache

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Build Status](https://scrutinizer-ci.com/g/sebastienheyd/boilerplate/badges/build.png?b=master&style=flat-square)](https://scrutinizer-ci.com/g/sebastienheyd/boilerplate/build-status/master)
55
[![StyleCI](https://github.styleci.io/repos/86598046/shield?branch=master&style=flat-square)](https://github.styleci.io/repos/86598046)
66
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/sebastienheyd/boilerplate/badges/quality-score.png?b=master&style=flat-square)](https://scrutinizer-ci.com/g/sebastienheyd/boilerplate/?branch=master)
7-
[![Laravel](https://img.shields.io/badge/Laravel-6.x%20→%2011.x-green?logo=Laravel&style=flat-square)](https://laravel.com/)
7+
[![Laravel](https://img.shields.io/badge/Laravel-6.x%20→%2012.x-green?logo=Laravel&style=flat-square)](https://laravel.com/)
88
[![Nb downloads](https://img.shields.io/packagist/dt/sebastienheyd/boilerplate.svg?style=flat-square)](https://packagist.org/packages/sebastienheyd/boilerplate)
99
[![MIT License](https://img.shields.io/github/license/sebastienheyd/boilerplate.svg?style=flat-square)](LICENSE)
1010

@@ -29,10 +29,10 @@ Other packages to extend the features :
2929

3030
## Version Compatibility
3131

32-
| Laravel | Boilerplate |
33-
|:----------------|:-------------------------------------------------------------|
34-
| 11.x | [8.x](https://sebastienheyd.github.io/boilerplate/docs/8.x/) |
35-
| 6.x → 10.x | [7.x](https://sebastienheyd.github.io/boilerplate/docs/7.x/) |
32+
| Laravel | Boilerplate |
33+
|:-----------------|:-------------------------------------------------------------|
34+
| 11.x → 12.x | [8.x](https://sebastienheyd.github.io/boilerplate/docs/8.x/) |
35+
| 6.x → 10.x | [7.x](https://sebastienheyd.github.io/boilerplate/docs/7.x/) |
3636

3737
## Documentation
3838

@@ -51,7 +51,6 @@ The documentation is readable on [Github pages](https://sebastienheyd.github.io/
5151
* Menu items activated by [sebastienheyd/active](https://github.com/sebastienheyd/active)
5252
* Server-side datatables methods provided by [yajra/laravel-datatables](https://yajrabox.com/docs/laravel-datatables)
5353
* Image manipulation by [intervention/image](https://github.com/intervention/image)
54-
* Logs visualization by [arcanedev/log-viewer](https://github.com/ARCANEDEV/LogViewer)
5554
* Gravatar import by [creativeorange/gravatar](https://github.com/creativeorange/gravatar)
5655
* Default languages from [Laravel-Lang/lang](https://github.com/Laravel-Lang/lang)
5756
* Javascript session keep-alive

composer.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
"require": {
1717
"php": ">=8.2",
1818
"ext-curl": "*",
19-
"arcanedev/log-viewer": "^11.0",
2019
"creativeorange/gravatar": "^1.0",
21-
"illuminate/support": "^11.0",
20+
"illuminate/support": "^12.0",
2221
"intervention/image-laravel": "^1.2",
2322
"laravel/ui": "^4.0",
2423
"lavary/laravel-menu": "^1.8",
@@ -28,14 +27,14 @@
2827
"santigarcor/laratrust": "^8.0",
2928
"sebastienheyd/active": "^1.0",
3029
"spatie/laravel-html": "^3.0",
31-
"yajra/laravel-datatables-oracle": "^11.0"
30+
"yajra/laravel-datatables-oracle": "^11.0|^12.0"
3231
},
3332
"require-dev": {
3433
"doctrine/dbal": "^3.0",
3534
"fakerphp/faker": "^1.20",
36-
"orchestra/testbench": "^9.0",
37-
"phpunit/php-code-coverage": "^10.0",
38-
"phpunit/phpunit": "^10.0|^11.0",
35+
"orchestra/testbench": "^9.0|^10.0",
36+
"phpunit/php-code-coverage": "^10.0|^11.0|^12.0",
37+
"phpunit/phpunit": "^10.0|^11.0|^12.0",
3938
"squizlabs/php_codesniffer": "^3.0"
4039
},
4140
"suggest": {

docs/docs/7.x/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ Other packages to extend the features :
4141
* Menu items activated by [sebastienheyd/active](https://github.com/sebastienheyd/active)
4242
* Server-side datatables methods provided by [yajra/laravel-datatables](https://yajrabox.com/docs/laravel-datatables)
4343
* Image manipulation by [intervention/image](https://github.com/intervention/image)
44-
* Logs visualization by [arcanedev/log-viewer](https://github.com/ARCANEDEV/LogViewer)
4544
* Gravatar import by [creativeorange/gravatar](https://github.com/creativeorange/gravatar)
4645
* Default languages from [laravel-lang/lang](https://github.com/Laravel-Lang/lang)
4746
* Javascript session keep-alive

docs/docs/8.x/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ Other packages to extend the features :
4141
* Menu items activated by [sebastienheyd/active](https://github.com/sebastienheyd/active)
4242
* Server-side datatables methods provided by [yajra/laravel-datatables](https://yajrabox.com/docs/laravel-datatables)
4343
* Image manipulation by [intervention/image](https://github.com/intervention/image)
44-
* Logs visualization by [arcanedev/log-viewer](https://github.com/ARCANEDEV/LogViewer)
4544
* Gravatar import by [creativeorange/gravatar](https://github.com/creativeorange/gravatar)
4645
* Default languages from [laravel-lang/lang](https://github.com/Laravel-Lang/lang)
46+
* Logs visualization
4747
* Javascript session keep-alive
4848
* Dark mode
4949
* [Localized](https://github.com/sebastienheyd/boilerplate/tree/master/src/resources/lang)

docs/docs/8.x/upgrade.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ Boilerplate 8.x requires at least PHP 8.2 and Laravel 11.x
77
## What's new in 8.x
88

99
- PHP >= 8.2
10-
- [Laravel 11.x](https://laravel.com/docs/11.x)
11-
- [Arcanedev Log Viewer 11.x](https://github.com/ARCANEDEV/LogViewer)
12-
- [Intervention Image 3.x](http://image.intervention.io/) now with [Laravel Integration 1.x](https://github.com/Intervention/image-laravel)
13-
- [Nesbot Carbon 3.x](https://carbon.nesbot.com/)
14-
- [Laratrust 8.x](https://laratrust.santigarcor.me/)
15-
- [Laravel Datatables 11.x](https://yajrabox.com/docs/laravel-datatables/master)
16-
- [PHPUnit 11.x](https://phpunit.de/)
17-
- [Laravel Orchestra Testbench 9.x](https://packages.tools/testbench.html)
10+
- [Laravel >= 11.x](https://laravel.com/docs/)
11+
- [Intervention Image >= 3.x](http://image.intervention.io/) now with [Laravel Integration 1.x](https://github.com/Intervention/image-laravel)
12+
- [Nesbot Carbon >= 3.x](https://carbon.nesbot.com/)
13+
- [Laratrust >= 8.x](https://laratrust.santigarcor.me/)
14+
- [Laravel Datatables >= 11.x](https://yajrabox.com/docs/laravel-datatables/master)
15+
- [PHPUnit >= 11.x](https://phpunit.de/)
16+
- [Laravel Orchestra Testbench >= 9.x](https://packages.tools/testbench.html)
17+
- Replaced Arcanedev Log Viewer (which seems to be no longer maintained) with a custom solution.
1818

1919
## Upgrade steps
2020

phpcs.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
</rule>
2323
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
2424
<rule ref="Generic.Formatting.SpaceAfterCast"/>
25-
<rule ref="Generic.Functions.CallTimePassByReference"/>
2625
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
2726
<rule ref="Generic.Functions.OpeningFunctionBraceBsdAllman"/>
2827
<rule ref="Generic.Metrics.CyclomaticComplexity">
@@ -50,7 +49,6 @@
5049
<property name="tabIndent" value="true"/>
5150
</properties>
5251
</rule>
53-
<rule ref="MySource.PHP.EvalObjectFactory"/>
5452
<rule ref="PSR1.Classes.ClassDeclaration"/>
5553
<rule ref="PSR1.Files.SideEffects"/>
5654
<rule ref="PSR2.Classes.ClassDeclaration"/>
@@ -104,7 +102,6 @@
104102
<rule ref="Squiz.Scope.StaticThisUsage"/>
105103
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
106104
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing"/>
107-
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
108105
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
109106
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
110107
<properties>
@@ -116,7 +113,6 @@
116113
<property name="ignoreNewlines" value="true"/>
117114
</properties>
118115
</rule>
119-
<rule ref="Squiz.WhiteSpace.PropertyLabelSpacing"/>
120116
<rule ref="Squiz.WhiteSpace.ScopeClosingBrace"/>
121117
<rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing"/>
122118
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>

src/BoilerplateServiceProvider.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
use Sebastienheyd\Boilerplate\Dashboard\Widgets\CurrentUser;
2020
use Sebastienheyd\Boilerplate\Dashboard\Widgets\LatestErrors;
2121
use Sebastienheyd\Boilerplate\Dashboard\Widgets\UsersNumber;
22+
use Sebastienheyd\Boilerplate\Datatables\Admin\LogFileDatatable;
23+
use Sebastienheyd\Boilerplate\Datatables\Admin\LogsDatatable;
2224
use Sebastienheyd\Boilerplate\Datatables\Admin\RolesDatatable;
2325
use Sebastienheyd\Boilerplate\Datatables\Admin\UsersDatatable;
2426
use Sebastienheyd\Boilerplate\Middleware\BoilerplateImpersonate;
@@ -198,9 +200,14 @@ public function register()
198200
'auth.providers.users.driver' => config('boilerplate.auth.providers.users.driver', 'eloquent'),
199201
'auth.providers.users.model' => config('boilerplate.auth.providers.users.model', 'App\User'),
200202
'auth.providers.users.table' => config('boilerplate.auth.providers.users.table', 'users'),
201-
'log-viewer.route.enabled' => false,
202-
'log-viewer.menu.filter-route' => 'boilerplate.logs.filter',
203203
'boilerplate.app.locale' => config('boilerplate.app.locale', config('boilerplate.locale.default')),
204+
'filesystems.disks.logs' => [
205+
'driver' => 'local',
206+
'root' => storage_path('logs'),
207+
'serve' => true,
208+
'throw' => false,
209+
'report' => false,
210+
],
204211
]);
205212

206213
if (config('boilerplate.app.logs', true) && ! in_array('daily', config('logging.channels.stack.channels'))) {
@@ -287,7 +294,12 @@ private function registerDatatables()
287294
return new Datatables\DatatablesRepository();
288295
});
289296

290-
app('boilerplate.datatables')->registerDatatable(UsersDatatable::class, RolesDatatable::class);
297+
app('boilerplate.datatables')->registerDatatable(
298+
UsersDatatable::class,
299+
RolesDatatable::class,
300+
LogsDatatable::class,
301+
LogFileDatatable::class
302+
);
291303
}
292304

293305
private function registerDashboardWidgets()

src/Controllers/Logs/LogViewerController.php

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,67 @@
22

33
namespace Sebastienheyd\Boilerplate\Controllers\Logs;
44

5-
use Arcanedev\LogViewer\Http\Controllers\LogViewerController as ArcanedevController;
6-
use Illuminate\Contracts\Foundation\Application;
7-
use Illuminate\Contracts\View\Factory;
8-
use Illuminate\Contracts\View\View;
5+
use Illuminate\Http\Request;
6+
use Sebastienheyd\Boilerplate\Models\LogFile;
97

10-
class LogViewerController extends ArcanedevController
8+
class LogViewerController
119
{
12-
protected $showRoute = 'boilerplate.logs.show';
13-
14-
/**
15-
* Get overloaded view.
16-
*
17-
* @param string $view
18-
* @param array $data
19-
* @param array $mergeData
20-
* @return Application|Factory|View
21-
*/
22-
protected function view($view, $data = [], $mergeData = [])
10+
public function index()
2311
{
24-
return view('boilerplate::logs.'.$view, $data, $mergeData);
12+
$logs = LogFile::files();
13+
$levels = LogFile::$levels;
14+
15+
$stats = [];
16+
foreach ($logs as $logFile) {
17+
$log = LogFile::get($logFile);
18+
$stats[$logFile] = $log->stats();
19+
}
20+
21+
return view('boilerplate::logs.index', compact('stats', 'levels'));
22+
}
23+
24+
public function show(string $date)
25+
{
26+
try {
27+
$log = LogFile::get("laravel-$date.log");
28+
} catch (\Exception $e) {
29+
abort(404);
30+
}
31+
32+
$stats = $log->stats();
33+
34+
return view('boilerplate::logs.show', compact('stats'));
35+
}
36+
37+
public function download(string $date)
38+
{
39+
try {
40+
$log = LogFile::get("laravel-$date.log");
41+
} catch (\Exception $e) {
42+
abort(404);
43+
}
44+
45+
return $log->download();
46+
}
47+
48+
public function delete(Request $request)
49+
{
50+
$validated = $request->validate([
51+
'date' => 'required|date',
52+
]);
53+
54+
$date = $validated['date'];
55+
56+
try {
57+
$log = LogFile::get("laravel-$date.log");
58+
} catch (\Exception $e) {
59+
abort(404);
60+
}
61+
62+
$deleted = $log->delete();
63+
64+
return response()->json([
65+
'success' => $deleted,
66+
]);
2567
}
2668
}

0 commit comments

Comments
 (0)