surface/laravel-webfinger

A Laravel package to create an ActivityPub webfinger.
4,475 13
Install
composer require surface/laravel-webfinger
Latest Version:v3.0.0
PHP:^8.2
License:MIT
Last Updated:Mar 17, 2026
Links: GitHub  ·  Packagist
Maintainer: trovster

Create a Webfinger in Laravel

This creates a webfinger, a way to attach information to an email address, or an other online resource. Once installed you should see your JSON webfinger profile at /.well-known/webfinger.

Installation

You can install the package via composer:

composer require surface/laravel-webfinger

You must add the configuration to your .env file:

WEBFINGER_INSTANCE=mastodon.instance
WEBFINGER_USERNAME=your-username

You can publish the config file with:

php artisan vendor:publish --provider="Surface\LaravelWebfinger\LaravelWebfingerServiceProvider"

Extending the Resource

The resource which is converted to the JSON response is bound to the service container. This allows you to easily override the resource and add extra information. To change the binding, add the following to your app service provider.

use App\Http\Resources\Webfinger as WebfingerResource;
use Surface\LaravelWebfinger\Http\Resources\Webfinger as PackageWebfinger;
use Surface\LaravelWebfinger\Service\Webfinger as WebfingerService;

$this->app->bind(
    PackageWebfinger::class,
    static fn (Container $app): WebfingerResource => new WebfingerResource(
        ...$app->make(WebfingerService::class)
    )
);

Then you would create your custom resource which extends the base.

<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Support\Stringable;
use Surface\LaravelWebfinger\Http\Resources\Webfinger as JsonResource;

class Webfinger extends JsonResource
{
    protected string $website;

    public function __construct(protected Stringable $instance, protected Stringable $username)
    {
        parent::__construct($instance, $username);

        $this->website = 'https://www.example.com';
    }

    public function links(Request $request): array
    {
        return [
            ...parent::links($request),
            [
                'rel' => 'self',
                'type' => 'text/html',
                'href' => $this->website,
            ],
        ];
    }
}

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.

Related Packages

revolution/laravel-mastodon-api

Mastodon API for Laravel

90,971 26
revolution/socialite-mastodon

Socialite for Mastodon

296,274 13
pixelfed/pixelfed

Open and ethical photo sharing platform, powered by ActivityPub federation.

408 7,121
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

637,827,751 9,703
laravel/framework

The Laravel Framework.

589,172,971 34,950

Version History

Version Released PHP Laravel License
v3.0.0 ^8.2 ^10.0|^11.0|^12.0|^13.0 MIT
v2.0.0 ^8.2 ^10.0|^11.0|^12.0 MIT
v1.2.1 ^8.1 ^9.0|^10.0|^11.0|^12.0 MIT
1.2.0 ^8.1 ^9.0|^10.0|^11.0 MIT
1.1.0 ^8.1 ^9.0|^10.0 MIT