Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Toon Laravel Package

sbsaga/toon

View on GitHub
Deep Wiki
Context7

Replacer Recipes

Replacers let you transform data before TOON encoding without changing your original payload.

Signature

fn (array $path, string|int|null $key, mixed $value): mixed
  • return Toon::skip() to remove a key or list item
  • return any other value to keep/transform it

Basic Usage

use Sbsaga\Toon\Facades\Toon;

$toon = Toon::encodeWith($payload, function (array $path, string|int|null $key, mixed $value) {
    if ($key === 'debug') {
        return Toon::skip();
    }

    return $value;
});

Recipe: Redact Secrets

$toon = Toon::encodeWith($payload, function (array $path, string|int|null $key, mixed $value) {
    if (in_array($key, ['email', 'token', 'api_key'], true)) {
        return '[redacted]';
    }

    return $value;
});

Recipe: Remove Internal Branches by Path

$toon = Toon::encodeWith($payload, function (array $path, string|int|null $key, mixed $value) {
    if ($path === ['meta'] && $key === 'trace') {
        return Toon::skip();
    }

    return $value;
});

Recipe: Normalize Scalars

$toon = Toon::encodeWith($payload, function (array $path, string|int|null $key, mixed $value) {
    if ($key === 'active') {
        return $value ? 'yes' : 'no';
    }

    return $value;
});

Helper Variant

$toon = toon_encode_with($payload, function (array $path, string|int|null $key, mixed $value) {
    return $key === 'debug' ? \Sbsaga\Toon\Toon::skip() : $value;
});

Notes

  • The replacer is called recursively for nested values.
  • Skipping at root level returns an empty TOON string.
  • Existing encode()/convert() behavior is unchanged if you do not use replacers.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity