PHP code example of georgringer / redirect-generator

1. Go to this page and download the library: Download georgringer/redirect-generator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

georgringer / redirect-generator example snippets


use GeorgRinger\RedirectGenerator\Event\BeforeRedirectAddedEvent;

class MyListener
{
    public function __invoke(BeforeRedirectAddedEvent $event): void
    {
        // Force all new redirects to 301
        $event->setConfiguration(
            new Configuration(targetStatusCode: 301)
        );
    }
}

use GeorgRinger\RedirectGenerator\Event\AfterRedirectAddedEvent;

class MyListener
{
    public function __invoke(AfterRedirectAddedEvent $event): void
    {
        // e.g. flush a custom cache, send a webhook, ...
    }
}