typhoon/exporter
Typhoon Exporter converts PHP values into valid PHP code strings you can save and later require to recreate the original value. Use Exporter::export($value) to generate code for config, fixtures, caching, or code generation workflows.
config.php for CLI tools or microservices).json_encode() + manual cleanup) when this package handles edge cases (e.g., circular references, complex objects) out-of-the-box.Adopt When:
JSON.stringify() + manual fixes).Look Elsewhere If:
msgpack or igbinary).json_encode() with custom handlers instead)."Typhoon Exporter is a lightweight, MIT-licensed PHP package that solves a common pain point: reliably exporting complex PHP data into clean, reusable formats. Think of it as a ‘save for later’ button for your developers—whether they’re generating config files for a new microservice, creating test data, or migrating legacy systems. It’s like json_encode() but smarter: handles edge cases (like circular references), produces human-readable output, and integrates seamlessly with Laravel. The cost? Minimal—just a Composer dependency. The payoff? Faster development cycles and fewer bugs from manual serialization."
Ask: "Where do we spend time today manually exporting data? Could this save [X] hours/month?"
*"This package fills a gap for teams that need to serialize PHP objects/arrays into exportable formats (e.g., PHP files, configs) without writing custom logic. Key benefits:
Exporter::export($data)) with built-in cleanup (no trailing commas, short vars).json_encode() or var_export() might break.Use Cases to Explore:
var_export() + manual fixes in your codebase.Trade-offs:
igbinary instead).json_decode() if needed.Proposal: Pilot this in [specific project/module] to replace [current workaround]. If successful, we can standardize it for [broader use case]."*
*"Tired of writing ugly var_export() hacks or debugging json_encode() failures? Typhoon Exporter does this better:
// Before:
$export = json_encode($complexObject, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
// ...then manually fix trailing commas, closures, etc.
// After:
$export = Exporter::export($complexObject);
file_put_contents('data.php', '<?php return '.$export.';');
Why it’s better:
✅ Handles everything json_encode() can’t (objects, resources, circular refs).
✅ Output is clean PHP code (no syntax errors, short vars).
✅ One dependency, no config needed.
Try it:
composer require typhoon/exportervar_export() or json_encode() + cleanup with Exporter::export().How can I help you explore Laravel packages today?