PHPackages                             rerout/laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. rerout/laravel

ActiveLibrary[API Development](/categories/api)

rerout/laravel
==============

Laravel integration for the Rerout branded-link API — service provider, facade, config, webhook controller, and events.

v0.3.0(1mo ago)00MITPHP ^8.2

Since May 22Compare

[ Source](https://github.com/ModestNerds-Co/rerout-laravel)[ Packagist](https://packagist.org/packages/rerout/laravel)[ Docs](https://rerout.co)[ RSS](/packages/rerout-laravel/feed)WikiDiscussions Synced 3w ago

READMEChangelogDependencies (14)Versions (3)Used By (0)

rerout/laravel
==============

[](#reroutlaravel)

Laravel integration for the [Rerout](https://rerout.co) API.

Wraps [`rerout/sdk`](https://packagist.org/packages/rerout/sdk) with a service provider, facade, config file, a webhook controller, and Laravel events — so short links, QR codes, analytics, and webhooks feel native in a Laravel app.

Install
-------

[](#install)

```
composer require rerout/laravel
```

Requires PHP 8.2+ and Laravel 10, 11, or 12. The package auto-registers its service provider and the `Rerout` facade via Laravel package discovery.

Publish the config file if you want to tweak defaults:

```
php artisan vendor:publish --tag=rerout-config
```

Configuration
-------------

[](#configuration)

Set these in your `.env`:

```
REROUT_API_KEY=rrk_…
REROUT_WEBHOOK_SECRET=whsec_…
REROUT_BASE_URL=https://api.rerout.co   # optional
REROUT_TIMEOUT=30                       # optional, seconds
```

The published `config/rerout.php` also exposes the webhook tolerance window and route settings — see the file's inline comments.

Usage
-----

[](#usage)

### The client

[](#the-client)

The service provider binds a shared `Rerout\Rerout` singleton. Resolve it any way Laravel allows — constructor injection, the container, or the facade.

```
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
```

Constructor injection works too:

```
use Rerout\Rerout;

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

The full client surface — `links()`, `project()`, `qr()` — is documented in the [base SDK README](https://packagist.org/packages/rerout/sdk).

### Verifying the API key

[](#verifying-the-api-key)

```
php artisan rerout:ping
```

Calls `GET /v1/projects/me` and prints the resolved project. Exits non-zero on any API failure — handy for deploy smoke tests.

### Webhooks

[](#webhooks)

The package registers a `POST` route (default `rerout/webhook`, named `rerout.webhook`) backed by a controller that:

1. verifies the `X-Rerout-Signature` header against `REROUT_WEBHOOK_SECRET`,
2. returns **401** on a missing/invalid/expired signature,
3. returns **400** on a body that is not a JSON object,
4. dispatches a Laravel event and returns **200** otherwise.

Point your Rerout webhook endpoint at `https://your-app.test/rerout/webhook`.

Disable the bundled route (to mount the controller yourself) by setting `REROUT_WEBHOOK_ROUTE_ENABLED=false`, or change the path with `REROUT_WEBHOOK_ROUTE_PATH`.

Listen for the events:

Webhook `type`Event`link.clicked``Rerout\Laravel\Events\LinkClicked``qr.scanned``Rerout\Laravel\Events\QrScanned``domain.failed``Rerout\Laravel\Events\DomainFailed````
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)
    logger()->info('Link clicked', $event->payload);
});
```

Each event carries the full decoded payload in its readonly `$payload`property. Unknown event types still return 200 but dispatch nothing.

### Error handling

[](#error-handling)

Every client call throws `Rerout\Exceptions\ReroutException` on failure, with a stable `code()`, HTTP `status()`, and `isRateLimited()` / `isServerError()`flags. See the [base SDK README](https://packagist.org/packages/rerout/sdk)for the full list of error codes.

Local development
-----------------

[](#local-development)

```
composer install
composer test      # PHPUnit + Orchestra Testbench
composer analyse   # PHPStan, level 9
composer format    # php-cs-fixer
```

The `composer.json` includes a path repository pointing at `../php`, so the package builds against the local `rerout/sdk` checkout inside this workspace.

License
-------

[](#license)

MIT — see [LICENSE](../LICENSE).

Links
-----

[](#links)

- [Rerout](https://rerout.co)
- [Base PHP SDK — `rerout/sdk`](https://packagist.org/packages/rerout/sdk)
- [Workspace repository](https://github.com/ModestNerds-Co/rerout-sdks)

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance90

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~13 days

Total

2

Last Release

50d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/595d37695ae82443fe49534433413413198dd386e28d3d3c95fe59048257f09f?d=identicon)[modestnerd](/maintainers/modestnerd)

---

Tags

laravelwebhooksurl shortenerqr codesshort-linksreroutbranded-links

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rerout-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/rerout-laravel/health.svg)](https://phpackages.com/packages/rerout-laravel)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

813336.8k3](/packages/defstudio-telegraph)[api-platform/laravel

API Platform support for Laravel

58174.6k17](/packages/api-platform-laravel)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.6k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
