Laravel Community Tools by Tighten
Laravel Nova icon Nova Packages
N

Redirect Tester

This package is possibly abandoned. Please proceed with care.

Readme

A Laravel Nova tool for testing redirects

This is a laravel nova tool, where you can test visually if all your redirects are working as expected.

Animate

Table of content

  1. Why should I use this package?
  2. Installation
  3. Create tests
  4. Editing Groups
  5. Examples

Why should I use this package?

If you have a lot of old urls you have redirected to new ones (for example you changed the url structure, migrated to laravel or introduced new language specific urls) and you are using Laravel Nova, then this package can help you have an eye on these redirects.

This is especially important to keep your visitors and SEO power by preventing broken redirects.

Installation

You can install the package in to a Laravel app that uses Nova via composer:

composer require bernhardh/nova-redirect-tester

After that, run the builtin migrations, which will create 2 tables:

  • nova_redirect_tester: This are the tests
  • nova_redirect_tester_groups: With this, you can group your tests
php artisan migrate

Now you must register the tool with Nova. This is done in the tools method of the NovaServiceProvider.

// file app/Providers/NovaServiceProvider.php

public function tools()
{
    return [
        // ...
        \Bernhardh\NovaRedirectTester\NovaRedirectTester::make()
    ];
}

Now you will find the Redirect Tester menu entry in your Nova sidebar. Right now, there are no tests, please read on to find out, how to create new tests.

Create tests

You can either fill up the two database tables nova_redirect_tester and nova_redirect_tester_groups by yourself (for example with phpmyadmin) or you use Nova to manage this. The easiest way to to this, is to create the two Nova resources, by extending the package nova resources:

<?php
// File app/Nova/RedirectTestGroup

namespace App\Nova;

class RedirectTestGroup extends \Bernhardh\NovaRedirectTester\Nova\RedirectTestGroup {}
<?php
// File app/Nova/RedirectTest

namespace App\Nova;

class RedirectTest extends \Bernhardh\NovaRedirectTester\Nova\RedirectTest {}

Now you can add a new test like any other nova resource.

Editing Groups

The Group resource is hidden by default in your sidebar. You can change that, by adding public static $displayInNavigation = true; to your App\Nova\RedirectTestGroup class.

Examples

If you wanna try it out, just add the following routes to your routes/web.php:

// routes/web.php
Route::get('cms/categories/articles/{article}.htm', function($article){
    return redirect('articles/' . $article);
});
Route::get('static-site/{article}.html', function($article){
    return redirect('articles/' . $article);
});
Route::get('articles/{article}', function($article){
    return '<h1>' . $article . '</h1>';
});

and then add the following Redirect Tests in nova:

Group Status Code Url From Url To
Articles 301 /cms/categories/articles/my-first-article.htm /articles/my-first-article
Articles 301 /cms/categories/articles/the-2-article.htm /articles/the-2-article
Articles 301 /static-site/prices /articles/prices
Default 404 /this-url-does-not-exist
Default 301 /my-old-url /this-test-will-fail

This will result in the following:

image

Screenshots

Reviews

By composer on December 19, 2022

Currently not works Class Bernhardh\NovaRedirectTester\NovaRedirectTester contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Laravel\Nova\Tool::menu)

Back to Top
Added 5 years ago
Last updated 5 Years Ago
Version 0.1.0
Composer
bernhardh/nova-redirect-tester
GitHub stars 0
Packagist downloads 95

Favorites

1 user favorited

Rating

1.00
(out of 5)
★★★★★
★★★★
★★★
★★
1 ratings

Brought to you by Tighten

Issues/Feature Requests Stats Package Ideas