Skip to content

Add guide about using Statamic alongside Laravel Nightwatch #1745

@duncanmcclean

Description

@duncanmcclean

If you're not careful, installing Laravel Nightwatch in a Statamic project can be a sure-fire way to run through your Nightwatch event quota.

I've previously written in detail about why this happens in a GitHub discussion but we should probably mention it on the docs as well.

You can either workaround it by ignoring all cache events via an env variable:

NIGHTWATCH_IGNORE_CACHE_EVENTS=true

Alternatively, you could filter out Statamic's cache keys so you can retain logging about your app's own cache events:

Or... you can filter out Statamic's cache keys:

use Illuminate\Support\Str;
use Laravel\Nightwatch\Facades\Nightwatch;
use Laravel\Nightwatch\Records\CacheEvent;

Nightwatch::rejectCacheEvents(function (CacheEvent $cacheEvent) {
    return Str::startsWith($cacheEvent->key, 'stache::'); 
});

^ Not all cache events start with stache:: so we'd likely want to improve this snippet before documenting.

You may also want to reject Statamic's HandleEntrySchedule job from being sent to Nightwatch as it is executed every minute:

Nightwatch::rejectQueuedJobs(function (QueuedJob $job): bool {
    return $job->name === \Statamic\Jobs\HandleEntrySchedule::class;
});

When we add the Nightwatch guide, we should link to it from the Debugging page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions