Weave 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

Yaml Export Bundle Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Install via Composer (Symfony2-era package, so expect an older constraint):
    composer require psamatt/yaml-export-bundle
    
  2. Register the bundle in app/AppKernel.php:
    $bundles = array(
        // ...
        new Psamatt\YamlExportBundle\PsamattYamlExportBundle(),
    );
    
  3. Look first at 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.
  4. Check the bundle's exporter class (typically under Exporter/ or Service/) for the public method(s) — usually a single export()/dump() that takes an array or object and returns (or writes) YAML.
  5. First use case — dump a config array to a file from a controller or command:
    $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.

Implementation Patterns

  • Service injection over container lookups. Inject the exporter into your own services via constructor or setter injection and tag/alias it in your app config. This keeps it testable and decouples you from the bundle's service ID.
  • Command-driven exports. The most natural fit is a Symfony console command (e.g. 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.
  • Config/seed data generation. Use it to emit YAML fixtures or snapshot configuration from a Doctrine repository — build a plain PHP array from entities first, then hand it to the exporter. Avoid passing entities directly; convert to arrays so you control the structure.
  • Compose with Symfony's Serializer for normalization. Run objects through 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.
  • Batch exports. For multiple datasets, create one exporter call per dataset and write to separate files (or a single concatenated stream with explicit --- separators if the exporter supports a document delimiter).
  • Testing. In unit tests, mock the exporter interface and assert the array you pass. In integration tests, write to a temp path and compare against a golden YAML fixture.

Gotchas and Tips

  • Symfony2 legacy. This bundle targets the Symfony2 era. On Symfony 3+/4+ you will hit 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.
  • Very low adoption (1 star, 0 dependents). Treat it as unmaintained. Pin the version in 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.
  • YAML formatting quirks. Symfony's YAML dumper (likely what's underneath) will render dates, booleans, and numeric-looking strings in ways that can surprise you ("yes", "1.0", ISO dates). Validate round-trips with Yaml::parse() in a test rather than eyeballing output.
  • Indentation and inline levels. If the exporter accepts an inline/depth argument, set it explicitly and consistently; otherwise large nested arrays become unreadable diffs in version control.
  • Escaping and encoding. Multibyte strings and strings containing :, #, 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 writing is not the bundle's job. The exporter likely returns a string. Handle atomic writes (file_put_contents to a temp file + rename) yourself so a failed export doesn't leave a truncated file.
  • Extension points are minimal. With such a small surface area, customization is best done by wrapping the service in your own class rather than trying to override bundle internals — the low star count means internal classes are unlikely to be stable across releases.
  • Debugging. Use 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.
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.
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource