Differences from PHP | laravel-webhook-server-go | Spatie       

 SPATIE  

laravel-webhook-server-go
=========================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-webhook-server-go](https://spatie.be/docs/laravel-webhook-server-go/v1)  Differences from PHP

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/laravel-webhook-server-go/v1) 

  Differences from PHP    
- [ Introduction ](https://spatie.be/docs/laravel-webhook-server-go/v1/introduction)
- [ Installation and setup ](https://spatie.be/docs/laravel-webhook-server-go/v1/installation-and-setup)
- [ Sending webhooks ](https://spatie.be/docs/laravel-webhook-server-go/v1/sending-webhooks)
- [ Signing requests ](https://spatie.be/docs/laravel-webhook-server-go/v1/signing-requests)
- [ Retrying failed webhooks ](https://spatie.be/docs/laravel-webhook-server-go/v1/retrying-failed-webhooks)
- [ Transport options ](https://spatie.be/docs/laravel-webhook-server-go/v1/transport-options)
- [ Events ](https://spatie.be/docs/laravel-webhook-server-go/v1/events)
- [ Testing webhooks ](https://spatie.be/docs/laravel-webhook-server-go/v1/testing-webhooks)
- [ Differences from PHP ](https://spatie.be/docs/laravel-webhook-server-go/v1/upgrading)
- [ Testing ](https://spatie.be/docs/laravel-webhook-server-go/v1/testing)
- [ Releasing ](https://spatie.be/docs/laravel-webhook-server-go/v1/releasing)
- [ Changelog ](https://spatie.be/docs/laravel-webhook-server-go/v1/changelog)
- [ Support us ](https://spatie.be/docs/laravel-webhook-server-go/v1/support-us)

 Differences from PHP
====================

###  On this page 

1. [ Requirements and deployment ](#content-requirements-and-deployment)
2. [ Custom signers receive the serialized body ](#content-custom-signers-receive-the-serialized-body)
3. [ Response and exception types ](#content-response-and-exception-types)
4. [ Custom HTTP clients and job subclasses ](#content-custom-http-clients-and-job-subclasses)
5. [ Delivery IDs and retry options ](#content-delivery-ids-and-retry-options)
6. [ Queued listeners and snapshots ](#content-queued-listeners-and-snapshots)
7. [ HTTP behavior and application-wide configuration ](#content-http-behavior-and-application-wide-configuration)

Requirements and deployment
-----------------------------------------------------------------------------------------------------------------------------------------

This is a Go port of `spatie/laravel-webhook-server`, targeting Go 1.27 and Laravel Go v0.1.0. Its first release is v0.1.0. The website's v1 docs alias is not a v1 Go release.

Register `webhookserver.New()` explicitly. There is no Composer discovery or published PHP config. Callbacks change typed configuration after environment defaults. Drain PHP jobs before switching applications. PHP, Rust and Go queue payloads are not interchangeable.

Custom signers receive the serialized body
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Implement `Signer` with `HeaderName` and `Sign`. The latter receives the URL, prepared bytes and secret. Raw bytes are not JSON-encoded. The secret is absent from serialized jobs.

The body is prepared before dispatch and reused on every attempt. Replace `Config.Serialize` instead of overriding `generateBody`. The serializer must not depend on worker-only state. The default uses deterministic Go JSON, whose escaping and map order may differ from PHP. Receivers should verify the raw received bytes.

GET requests use explicit `url.Values` and no body. `Query` defaults the signed payload to those values. Call `Payload` after `Query` to choose a PHP-compatible JSON shape. Raw GET calls are rejected. JSON payloads must be encodable even for unsigned requests.

Response and exception types
--------------------------------------------------------------------------------------------------------------------------------------------

Methods return Go errors. Validation fails before dispatch. Result events carry a buffered `Response`, an error type string, an error message and elapsed time. HTTP failures use `httpclient.StatusError` and connection failures use `httpclient.ConnectionError`.

There are no Guzzle cookie jars, PSR streams, original response subclasses or Guzzle transfer-stat objects. Status, headers, body and final URL survive queued event listeners. Use a custom HTTP hook or transport for native tracing.

Custom HTTP clients and job subclasses
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Use `Config.Client` for request and transport customization. Build from its supplied `*httpclient.Client` to retain global hooks and Laravel fakes.

Register a replacement native job constructor. The package registers the actual selected type, not just the default job:

```
type CustomWebhookJob struct {
    webhookserver.CallWebhookJob
}

func (j CustomWebhookJob) Handle(ctx context.Context) error {
    j.Delivery.Headers.Set("X-Source", "custom-job")
    return j.CallWebhookJob.Handle(ctx)
}

webhookserver.New(func(cfg *webhookserver.Config) {
    cfg.Jobs["custom"] = webhookserver.Job(func(d webhookserver.Delivery) CustomWebhookJob {
        return CustomWebhookJob{CallWebhookJob: webhookserver.CallWebhookJob{Delivery: d}}
    })
    cfg.Job = "custom"
})
```

Custom jobs may replace `Handle`, `JobOptions`, `Failed`, middleware or other native job behavior. Embed `CallWebhookJob` or delegate to it to retain package delivery and retry handling. Do not modify a signed body without replacing its signature. Use named struct fields if your job needs its own serialization methods.

Register several constructors in `cfg.Jobs` and call `UseJob("custom")` for per-call selection. All named job types must be registered on every worker. `Config.ShouldStop` replaces `shouldBeRemovedFromQueue`, and named `Config.Backoffs` functions replace backoff classes.

The PHP package has no models or profile classes to replace. No persistence model is introduced by this port.

Delivery IDs and retry options
--------------------------------------------------------------------------------------------------------------------------------------------------

The default `Webhook-Id` header stays the same across attempts. Set `IDHeader` to an empty string to disable it. Explicit caller headers take precedence regardless of casing. Neither the ID nor optional timestamp is authenticated by the default signer.

`RetryableStatuses`, `RespectRetryAfter` and `Jitter` preserve the PHP retry policy. Sync calls perform one attempt without sleeping. A final failed delivery is deleted by default, or marked failed with `ThrowOnFailure`.

Queued listeners and snapshots
--------------------------------------------------------------------------------------------------------------------------------------------------

Register native listeners with `laravel.Listen` or `laravel.ListenQueued`. Byte slices preserve binary bodies through base64 JSON. Result events are buffered snapshots and have no stream cursor. Metadata is JSON, and headers must be valid HTTP strings. Queue data is not encrypted.

HTTP behavior and application-wide configuration
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Only final `2xx` responses succeed. Go follows up to ten redirects using its standard method and credential-forwarding rules instead of Guzzle's policy. No cookies are retained. Explicit transport options replace matching framework transport settings.

TLS certificates are verified by default. Mutual TLS and custom CA bundles use PEM paths readable on workers. Encrypted key passphrases are not supported as serialized options. Load and decrypt encrypted keys in application configuration and return an in-memory transport through `Config.Client`.

Tags remain on jobs and events. Laravel Go does not have PHP Horizon integration. This package does not promise Horizon's dashboard or Guzzle-specific APIs.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
