Distribution Polish for Laravel Packages

9 min readUpdated on

The first minute after composer require decides whether a package feels trustworthy. A README is an adoption path, not a sales page and not a dump of every class in src/: install the package, configure the one value that matters, run one command or make one call, and observe a useful result. Architecture, extension points and release history can come after that first success.

Use a concrete package throughout: laravel-webhook-tap receives verified webhook deliveries and stores them for inspection. The release discipline applies equally to mail, billing and admin packages. Unclear installation instructions produce broken production configuration and support tickets.

Write the shortest successful path first

Start the README with requirements and the exact installation sequence. Do not make the reader infer whether migrations are automatic, whether package discovery is used, or which config tag to publish.

md
## Requirements

- PHP 8.3 or newer
- Laravel 11, 12 or 13

## Install

```bash
composer require dominik-dev/laravel-webhook-tap
php artisan vendor:publish --tag=webhook-tap-config
php artisan migrate
```

Set `WEBHOOK_TAP_SECRET` in `.env`, then add the route shown below.

The command order is part of the product: publishing configuration before the reader sees the route tells them where the secret comes from. List php artisan migrate whenever the package owns a table, or the failure surfaces on the first delivery. If the package auto-discovers its migrations, say so explicitly and do not ask users to run a redundant publish command.

Then show one complete route. The billing-webhooks limiter is a name the application defines with RateLimiter::for(); say so next to the example. A reader should be able to paste it into a fresh application without needing to guess imports, middleware or controller syntax.

php
<?php

declare(strict_types=1);

use DominikDev\WebhookTap\Http\Controllers\WebhookDeliveryController;
use Illuminate\Support\Facades\Route;

Route::post('/webhooks/billing', WebhookDeliveryController::class)
    ->middleware('throttle:billing-webhooks')
    ->name('webhooks.billing');

The example deliberately does not claim that CSRF middleware is required or removed: that depends on the application's API/web middleware topology. Explain the required property instead: this endpoint must accept the provider's request and be rate-limited at an application-appropriate boundary. Documentation that blindly says “exclude this from CSRF” is a security footgun disguised as a copy-and-paste instruction.

Make configuration discoverable and safe

Document configuration by showing the shipped file, its defaults and the effect of each value. Avoid a table that drifts away from real code. This example has no env() calls outside a config file and no secret hard-coded in a route.

php
<?php

declare(strict_types=1);

return [
    'secret' => env('WEBHOOK_TAP_SECRET'),
    'signature_header' => 'X-Billing-Signature',
    'store_payloads' => true,
    'retention_days' => 30,
];

Explain that the package reads config('webhook-tap.secret'), not env() at runtime, so config:cache remains valid. Explain what happens when a required secret is absent: fail on boot with a useful exception, reject every delivery, or allow a disabled local mode. Pick one and make it the documented default. In a security-sensitive integration, silently accepting unsigned deliveries is never a convenient default.

The first public call site should be just as complete. Here a controller gets the recorder from Laravel's container rather than using a facade that hides its dependencies:

php
<?php

declare(strict_types=1);

namespace App\Http\Controllers;

use DominikDev\WebhookTap\WebhookRecorder;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

final class BillingWebhookController
{
    public function __invoke(Request $request, WebhookRecorder $recorder): Response
    {
        $recorder->record(
            payload: $request->getContent(),
            signature: (string) $request->header('X-Billing-Signature'),
        );

        return response()->noContent();
    }
}

When a package provides a facade, show both the facade and the injectable contract, and recommend the contract in application code so dependencies stay visible and tests can replace the service.

Prove the documented path in the package suite

The README is a contract. Test its important steps through Orchestra Testbench: provider discovery, configuration merging, migration availability and expected failure. This Pest test verifies behaviour a consumer relies on rather than an implementation detail of the provider.

php
<?php

declare(strict_types=1);

use DominikDev\WebhookTap\Exceptions\InvalidSignature;
use DominikDev\WebhookTap\Tests\PackageTestCase;
use DominikDev\WebhookTap\WebhookRecorder;
use Illuminate\Foundation\Testing\RefreshDatabase;

uses(PackageTestCase::class, RefreshDatabase::class);

it('records a verified delivery using the published configuration', function (): void {
    config()->set('webhook-tap.secret', 'top-secret');

    app(WebhookRecorder::class)->record(
        payload: '{"id":"evt_123"}',
        signature: hash_hmac('sha256', '{"id":"evt_123"}', 'top-secret'),
    );

    $this->assertDatabaseHas('webhook_deliveries', [
        'external_id' => 'evt_123',
    ]);
});

it('rejects a delivery with an invalid signature', function (): void {
    config()->set('webhook-tap.secret', 'top-secret');

    app(WebhookRecorder::class)->record('{"id":"evt_123"}', 'invalid');
})->throws(InvalidSignature::class);

If a README says vendor:publish is optional, test the no-publish case. If it says a command is idempotent, test repeated execution. If it shows a middleware alias, boot an application that resolves the alias.

Release notes answer a different question

README answers “how do I begin today?” A changelog answers “what changed since the version I run?” Keep them separate. Use a human-readable changelog with Added, Changed, Deprecated, Removed, Fixed and Security sections. Link release headings to tags and link every major release to an upgrade guide.

An upgrade guide must name observable work. “Update configuration” is not enough; show the old and new keys, state whether the migration is additive or destructive, identify deployment order, and give a rollback boundary. For example, if version 3 stores encrypted payloads, an operator needs to know the encryption key must exist before workers consume deliveries. They also need to know whether rolling application code back can read rows written by version 3.

Keep badges to what a reader can act on: CI status, latest stable release, license and supported PHP/Laravel range. Ten badges, download counters and fashionable tooling logos make readers search harder for the install command.

Give security reports a private route

SECURITY.md should state a monitored private reporting mechanism, expected acknowledgement time, supported version window and coordination expectations. Do not ask a reporter to disclose a signature-bypass issue in a public GitHub issue. Do not promise a response window your project cannot meet. A modest, honest policy is better than copied enterprise language nobody reads.

Security documentation also draws a useful line: package configuration examples must use placeholders; real secrets do not belong in an issue, README, fixture or test snapshot. For webhook packages, document replay and duplicate-delivery behaviour. Signature validity proves origin, not uniqueness, so consumers need to know whether the package stores an external event ID, rejects duplicates, or leaves idempotency to the application.

When polish is not another documentation file

Do not create a documentation site, a separate “core” package, or versioned manuals for a package with one stable major and a three-command setup; each is another place for instructions to drift. A strong README, changelog, SECURITY.md and one upgrade guide are enough for many maintained packages.

A polished README does not replace compatibility testing: a beautiful install section cannot prove the provider boots on every claimed Laravel version. Keep the distribution surface lean and back it with CI and Testbench tests.

Publish a release, not the contents of your laptop

The repository also needs a small release checklist. Before tagging, run the same checks that protect pull requests, inspect the package contents, and test installation into an empty Laravel application. The last step catches a class of mistakes that unit tests do not: a file excluded by .gitattributes, a missing migration, an accidentally committed local path repository, or a README command that only works because the package is checked out beside the example app.

bash
composer validate --strict
composer test
composer archive --format=tar --dir=/tmp --file=laravel-webhook-tap
tar -tf /tmp/laravel-webhook-tap.tar | sort

composer archive is particularly useful for libraries. Composer installs the distributed archive, not your working directory. Keep tests, CI definitions and development notes out of the archive when that reduces download size, but never exclude source files, migration stubs, config files or the licence. Then create a disposable application, require the tagged version rather than dev-main, and follow the README exactly. Run this gate whenever a change touches package discovery, publishable assets, Composer metadata or an upgrade path; a typo fix does not need it.

The manifest states the same promise in machine-readable form:

json
{
  "name": "dominik-dev/laravel-webhook-tap",
  "type": "library",
  "require": {
    "php": "^8.3",
    "illuminate/support": "^11.0|^12.0|^13.0"
  },
  "extra": {
    "laravel": {
      "providers": [
        "DominikDev\\WebhookTap\\WebhookTapServiceProvider"
      ]
    }
  }
}

Do not copy a broad constraint just to increase a badge's range. Supporting a Laravel version means the provider, commands, migrations and documented path are tested there. A consumer can disable package discovery, so keep manual registration instructions in a short troubleshooting section rather than in the main path.

Treat deprecation as a release feature

Breaking a public class name or configuration key without a migration path turns routine maintenance into emergency work for users. When a change can be introduced gradually, document the old and new APIs together, emit a clear deprecation message where appropriate, and state the first release where the old path will disappear. A practical changelog entry tells readers whether they need a code edit, a config edit, a database migration, or no action at all.

For example, if WEBHOOK_TAP_SECRET becomes WEBHOOK_TAP_SECRETS, version 2 can accept both values while preferring the new one. Version 3 can remove the fallback after the upgrade guide has had one major release to do its job. Do not silently choose between conflicting values: fail fast during boot and name both keys. Silent precedence rules create incidents that cannot be reconstructed from a release note.

Shipping only major releases and asking every user to read the diff can work for a private, tightly coordinated package. For an open package with unknown deployment schedules it is a poor default; a few paragraphs of compatibility notes cost less than every adopter reverse-engineering your intent.

Related articles

Dominik Jasiński

Dominik Jasiński

Laravel & PHP developer · freelance and B2B subcontracting

Existing system support

Need help with a live application?

I help companies improve live systems, clean up delivery workflows, and ship new features without adding avoidable complexity.

For software houses & agencies
Comments (0)
Sign in to leave a comment

You need to be signed in to add a comment.

Login