psamatt/yaml-export-bundle
psamatt/yaml-export-bundle is a Symfony bundle that adds YAML export support to your application. It provides container-integrated services for converting data and configuration into YAML files, simplifying exports for backups, fixtures, or data interchange.
composer require psamatt/yaml-export-bundle
app/AppKernel.php:
$bundles = array(
// ...
new Psamatt\YamlExportBundle\PsamattYamlExportBundle(),
);
Resources/config/services.yml in the bundle — that is where the exporter service ID and its dependencies are defined. That service is the public entry point you will inject everywhere else.Exporter/ or Service/) for the public method(s) — usually a single export()/dump() that takes an array or object and returns (or writes) YAML.$yaml = $this->get('psamatt.yaml_export.exporter')->export($data);
file_put_contents($path, $yaml);
If the service ID differs from the above, confirm it with php app/console container:debug | grep -i yaml.
app/console app:export:yaml) that pulls data from a repository and writes a file. Wire the exporter into the command's constructor and keep the write path in configuration.serializer->normalize() and feed the resulting array to the exporter. This lets the exporter stay a thin formatting layer while the serializer handles dates, nested objects, and circular references.--- separators if the exporter supports a document delimiter).AppKernel, service-visibility, and PHP version issues. Budget time for a fork or a thin wrapper around symfony/yaml if you are on a modern stack.composer.json, and be prepared to vendor-fork it. Read the exporter source before relying on it — it is small enough to audit in minutes."yes", "1.0", ISO dates). Validate round-trips with Yaml::parse() in a test rather than eyeballing output.:, #, or leading - need quoting. Confirm the exporter quotes them; if not, post-process or switch to Symfony\Component\Yaml\Yaml::dump() with adequate flags.file_put_contents to a temp file + rename) yourself so a failed export doesn't leave a truncated file.container:debug to confirm the service is public and instantiated; if get() fails, the bundle may not be registered or the service may be private depending on your Symfony version.How can I help you explore Laravel packages today?