PHP code example of rerout / laravel

1. Go to this page and download the library: Download rerout/laravel 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/ */

    

rerout / laravel example snippets


use Rerout\Laravel\Facades\Rerout;
use Rerout\Models\CreateLinkInput;

$link = Rerout::links()->create(new CreateLinkInput(
    targetUrl: 'https://example.com/q4-sale',
    domainHostname: 'go.brand.com',
    code: 'q4',
));

echo $link->shortUrl; // https://go.brand.com/q4

use Rerout\Rerout;

public function __construct(private readonly Rerout $rerout) {}

use Illuminate\Support\Facades\Event;
use Rerout\Laravel\Events\LinkClicked;

Event::listen(LinkClicked::class, function (LinkClicked $event) {
    // $event->payload is the decoded webhook body (array<string, mixed>)
    logger()->info('Link clicked', $event->payload);
});
bash
php artisan vendor:publish --tag=rerout-config
bash
php artisan rerout:ping