Installation and setup | laravel-honeypot-go | Spatie       

 SPATIE  

laravel-honeypot-go
===================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-honeypot-go](https://spatie.be/docs/laravel-honeypot-go/v1)  Installation and setup

 Version   v1      

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

  Installation and setup    
- [ Introduction ](https://spatie.be/docs/laravel-honeypot-go/v1/introduction)
- [ Installation and setup ](https://spatie.be/docs/laravel-honeypot-go/v1/installation-and-setup)
- [ Usage ](https://spatie.be/docs/laravel-honeypot-go/v1/usage)
- [ Testing ](https://spatie.be/docs/laravel-honeypot-go/v1/testing)
- [ Releasing ](https://spatie.be/docs/laravel-honeypot-go/v1/releasing)
- [ Changelog ](https://spatie.be/docs/laravel-honeypot-go/v1/changelog)
- [ Support us ](https://spatie.be/docs/laravel-honeypot-go/v1/support-us)

 Installation and setup
======================

###  On this page 

1. [ Configuration ](#content-configuration)

You can install the package with Go modules:

```
go get github.com/spatie/laravel-honeypot-go@v0.1.0
```

Requires Go 1.27 or newer and Laravel Go `go.laravel.com v0.1.0`. Add the package to `bootstrap/app.go`. Installing the module alone does not activate it.

```
import (
    honeypot "github.com/spatie/laravel-honeypot-go"
    laravel "go.laravel.com"
)

func Options() laravel.Options {
    return laravel.Options{
        Packages: []laravel.Package{
            honeypot.New(func(cfg *honeypot.Config) {
                cfg.FieldsRequired = true
            }),
        },
    }
}
```

Keep `APP_KEY` stable across all application servers. Laravel's native encryption supports `APP_PREVIOUS_KEYS` during key rotation. Missing or invalid keys are application errors, not successful spam checks. Registration does not generate tokens or protect any routes until you attach the middleware.

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

Unlike PHP, you do not publish a config file. The package reads Laravel's application environment, then applies the callbacks passed to `New`. A malformed typed environment value stops startup. Callbacks override valid environment defaults.

Config fieldEnvironment variableDefault`Enabled``HONEYPOT_ENABLED``true``NameFieldName``HONEYPOT_NAME``my_name``RandomizeNameFieldName``HONEYPOT_RANDOMIZE``true``ValidFromTimestamp``HONEYPOT_VALID_FROM_TIMESTAMP``true``ValidFromFieldName``HONEYPOT_VALID_FROM``valid_from``MinimumAge``HONEYPOT_SECONDS``time.Second``FieldsRequired``HONEYPOT_FIELDS_REQUIRED``false``Scope``HONEYPOT_SCOPE``honeypot``Checker`Code onlyBuilt-in checker`Responder`Code onlyEmpty 200 response`MinimumAge` is a nonnegative `time.Duration`. The environment value is a number of seconds, including fractional seconds. Field names must start with an ASCII letter, contain only letters, digits and underscores, and have at most 64 bytes. Neither name may start with the other. Scope must contain 1 to 128 bytes.

Set `FieldsRequired = true` when every submission to the protected route must carry honeypot fields. The PHP-compatible default is `false`, which lets requests through when both fields are absent. This default is convenient for global middleware but can be bypassed by omitting both fields. Do not use it on sensitive forms.

Use a different scope for independently purposed forms sharing the application key. Tokens authenticate the scope and exact field names as well as their earliest acceptance time. Do not use shared response caches for pages containing generated tokens. Tokens do not expire and can be replayed after the minimum age, matching PHP's absence of an expiration limit. Use CSRF and throttling separately.

There are no prerequisite Spatie Go ports or external binaries. The package uses the framework's registrar, encryption, clock, views and events. It does not depend on package-tools or CSP.

 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)
