gheb/api-platform-config-converter-bundle
Symfony bundle for converting API Platform configuration between formats, making it easier to migrate legacy YAML, XML, or annotation-based resource definitions to modern PHP attributes while reducing manual rewrite work. Useful when upgrading API Platform projects.
Install it as a dev-only dependency (it is a code-generation/migration tool, not runtime infrastructure):
composer require --dev gheb/api-platform-config-converter-bundle
If Flex does not auto-register it, add the bundle to config/bundles.php for dev/test only. Then look in this order:
README.md — the supported input/output format matrix and the exact command signature.src/Command/ — the console command name and its options (--from, --to, --output, dry-run flags).src/Converter/ (or similarly named namespace) — the service that actually performs the transformation, which is what you decorate or extend if you need a custom format.php bin/console list and php bin/console <command> --help — confirm the installed version's options rather than trusting the README.First use case: converting a single legacy resource definition (typically a YAML file under config/api_platform/) into XML or annotations while upgrading an API Platform 2.x project. Do it on a branch, commit the current config, run the converter on one resource, and diff the result. Once that resource behaves identically (compare bin/console debug:router and the exported OpenAPI document), repeat for the rest.
Branch-and-diff migration workflow. Never run the converter directly against your working tree on main. Create a branch, commit the existing config, run the converter into a separate output directory (--output=var/converted if supported, otherwise copy the source tree first), review the diff, then move files into place. This makes semantic regressions obvious and revertible.
Verify semantics, not just syntax. Before and after conversion, export the OpenAPI spec and compare:
bin/console api:openapi:export --yaml > var/openapi-before.yaml
# run converter, clear cache
bin/console cache:clear
bin/console api:openapi:export --yaml > var/openapi-after.yaml
diff -u var/openapi-before.yaml var/openapi-after.yaml
Also diff bin/console debug:router output. These two checks catch lost operations, wrong paths, dropped filters, and missing serialization groups far faster than manual review.
Convert one resource (or one directory) at a time. Large batch conversions produce enormous diffs that nobody reviews carefully. Convert, test, commit, repeat. Keep converted files under config/api_platform/ with the matching extension so API Platform's loader picks them up.
Chain with Rector for the final hop. The bundle handles the structural format change (YAML ↔ XML, annotations ↔ YAML/XML). If your target is PHP attributes on API Platform 3, use the bundle to get into annotations, then apply Rector's API Platform rulesets to finish the annotations → attributes step. Splitting the migration this way keeps each step reviewable.
Automate invocation in a Composer script or Makefile. A target like make convert-config that runs the command with -vvv and a fixed output directory makes the migration reproducible across team members and CI, and documents the exact invocation your project relies on.
Extend via services, not by editing vendor code. The converter is a Symfony service. If you need a custom format or post-processing (e.g., stripping docblock comments, reordering keys), decorate the converter service or add a compiler-pass-registered implementation of its interface. Check src/DependencyInjection/ for tags and configuration keys.
Pair with linters in CI. Run bin/console lint:yaml config/, xmllint --noout on generated XML, and php -l on generated PHP before committing. Converters are string/DOM emitters and occasionally produce edge-case output that only a linter will flag.
api-platform/core or Symfony versions, and no PHP attribute support from upstream. Pin the bundle and the API Platform version together in composer.json, and be prepared to fork. Treat it as a one-shot migration aid, not a long-term dependency.ApiResource options, filters, subresource definitions, and serializer metadata may not round-trip. The OpenAPI diff described above is your primary safety net. Anything that disappears must be re-added by hand.bin/console cache:clear before concluding anything.-vvv and watch var/log/dev.log. Failures in parsing a resource usually surface as a warning with the offending file path; without verbose mode they can be swallowed and you get incomplete output.require-dev. There is no reason for this bundle to be installed in production, and its archived status makes that doubly true.composer.json constraints may conflict with current Symfony versions; if composer require fails, try a constrained version or install it in a throwaway branch with --ignore-platform-reqs only for the conversion run.How can I help you explore Laravel packages today?