pardalsalcap / hailo-redirections
This is my package hailo-redirections
Fund package maintenance!
pardalsalcap
Requires
- php: ^8.1
- illuminate/contracts: ^10.0
- livewire/livewire: ^3.3
- pardalsalcap/hailo: dev-develop
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.8
- orchestra/testbench: ^8.8
- pestphp/pest: ^2.33
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.2
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-11-15 12:46:01 UTC
README
This is an add-on for Hailo that allows you to log 404 errors and create redirections for them.
Installation
You can install the package via composer:
composer require pardalsalcap/hailo-redirections
You can publish and run the migrations with:
php artisan vendor:publish --tag="hailo-redirections-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="hailo-redirections-config"
This is the contents of the published config file:
return [ '404' => true, ];
Optionally, you can publish the views using
php artisan vendor:publish --tag="hailo-redirections-views"
Usage
Add the render method into the app/Exceptions/Handler.php
file.
public function render($request, Throwable $e) { if ($e instanceof NotFoundHttpException) { $http_status = $e->getStatusCode(); $redirection_repository = new RedirectionRepository(); $redirection = $redirection_repository->logError(request()->fullUrl(), $http_status); if (!empty($redirection->fix)) { return redirect($redirection->fix, $redirection->http_status); } } return parent::render($request, $e); }
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.