定制 pardalsalcap/hailo-redirections 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pardalsalcap/hailo-redirections

最新稳定版本:v0.1.1

Composer 安装命令:

composer require pardalsalcap/hailo-redirections

包简介

This is my package hailo-redirections

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

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.

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-06