knackline/laravel-toon
A powerful Laravel package for integrating Toon functionality into your Laravel applications. Seamlessly add Toon features with elegant Laravel syntax.
8,320
1
| Install | |
|---|---|
composer require knackline/laravel-toon |
|
| Latest Version: | 1.0 |
| PHP: | ^7.2|^8.0|^8.1|^8.2|^8.3 |
| License: | MIT |
| Last Updated: | Dec 13, 2025 |
| Links: | GitHub · Packagist |
Maintainer: rajkumarsamra
Laravel Toon
A powerful Laravel package for converting between JSON and Toon format. Seamlessly transform your JSON data into a compact, human-readable Toon format and back again.
Installation
You can install the package via Composer:
composer require knackline/laravel-toon
The package will automatically register its service provider and facade.
Usage
Converting JSON to Toon Format
use Knackline\LaravelToon\Toon;
$jsonData = [
"context" => [
"task" => "Our favorite hikes together",
"location" => "Boulder",
"season" => "spring_2025"
],
"friends" => ["ana", "luis", "sam"],
"hikes" => [
[
"id" => 1,
"name" => "Blue Lake Trail",
"distanceKm" => 7.5,
"elevationGain" => 320,
"companion" => "ana",
"wasSunny" => true
]
]
];
$toon = Toon::fromJson($jsonData);
Output:
context:
task: Our favorite hikes together
location: Boulder
season: spring_2025
friends[3]: ana,luis,sam
hikes[3]{id,name,distanceKm,elevationGain,companion,wasSunny}:
1,Blue Lake Trail,7.5,320,ana,true
2,Ridge Overlook,9.2,540,luis,false
3,Wildflower Loop,5.1,180,sam,true
Converting Toon Format to JSON
$toonString = "context:
task: Our favorite hikes together
location: Boulder
season: spring_2025
friends[3]: ana,luis,sam
hikes[3]{id,name,distanceKm,elevationGain,companion,wasSunny}:
1,Blue Lake Trail,7.5,320,ana,true
2,Ridge Overlook,9.2,540,luis,false";
$jsonData = Toon::toJson($toonString);
Using the Facade
If you prefer using facades:
use Knackline\LaravelToon\Facades\Toon;
$toon = Toon::fromJson($data);
$json = Toon::toJson($toon);
Format Specification
Simple Values
key: value
Objects (Associative Arrays)
key:
nestedKey: value
anotherKey: value
Simple Arrays
key[count]: value1,value2,value3
Arrays of Objects
key[count]{field1,field2,field3}:
value1,value2,value3
value4,value5,value6
Supported Data Types
- Strings: Plain text values
- Numbers: Integers and floats (e.g.,
7.5,320) - Booleans:
trueandfalse - Null: Empty values
- Arrays: Both indexed and associative arrays
- Nested Objects: Multi-level object structures
Requirements
- PHP 8.1 or higher
- Laravel 9.0, 10.0, or 11.0
License
The MIT License (MIT). Please see the License File for more information.
Support
For issues, questions, or contributions, please visit the GitHub repository.
Related Packages
juniorb2ss/deathbycaptcha-php-sdk
With Death by Captcha you can solve any CAPTCHA. All you need to do is implement...
19,201
6
patinthehat/laravel-require
Add a package with composer, and automatically registers the service provider.
24
9