pardalsalcap / linter-redirections
Add on to manage 404 and redirections into linter and filament
Requires
- php: ^8.1
- filament/filament: ^3.0-stable
- illuminate/contracts: ^10.0|^11.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- larastan/larastan: ^2.0.1
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.8
- orchestra/testbench: ^8.8
- pestphp/pest: ^2.20
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
This package is auto-updated.
Last update: 2024-11-21 08:56:15 UTC
README
This package is and add on to the linter panel to manage 404 and redirections. It includes a filament resource for managng and redirecting 404 and 2 widgets for the dashboard to get the information of the 404 and redirections.
Installation
You can install the package via composer:
composer require pardalsalcap/linter-redirections
You can publish and run the migrations with:
php artisan vendor:publish --tag="linter-redirections-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="linter-redirections-config"
This is the contents of the published config file:
return [
];
Usage
To register the 404 or any Exception you like to monitor you can add the following code to your app/Exceptions/Handler.php
file:
use Pardalsalcap\HialoRedirections\Repositories\RedirectionRepository; public function render($request, Throwable $e) { switch(class_basename($e)){ case 'NotFoundHttpException': $http_status = $e->getStatusCode(); $redirection_repository = new RedirectionRepository(); $redirection = $redirection_repository->check(request()->fullUrl()); if ($redirection) { return redirect($redirection->fix, $redirection->http_status); } if ($http_status == "404") { $redirection_repository->logError(request()->fullUrl(), $http_status); } break; } return parent::render($request, $e); }
If you want to log any other exception you can add it to the switch case.
Resources
You can extend the RedirecionsResource to add the ability to manage the redirections from the filament panel. To do so you can create a Resource like this:
<?php namespace App\Filament\Resources; class RedirectionResource extends \Pardalsalcap\LinterRedirections\Resources\RedirectionResource { // Any additional logic here }
Widgets
To add the widgets to the dashboard you can add the following code to your filament panel widgets section:
RedirectionsStats::class, RedirectionsDashboardWidget::class,
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.