Introducing Neon to YAML Converter
Neon and YAML are basically arrays, right? So why not let a tool let do the dirty work?
- You want to migrate your package dependency injection component from
- You want to migrate your application from Nette to Symfony
- One of your dependency decided to migrate from
*.yaml, e.g. EasyCodingStandard 2 → 3, and you need to migrate your config, e.g. from
To use Symplify/NeonToYamlConverter, require it a composer dependency:
composer require symplify/neon-to-yaml-converter --dev
Run it on one file or directory - it takes all
vendor/bin/neon-to-yaml-converter convert file.neon
In Neon there are nested parameters = you can use
%payu.user% to get parameter
payu array. In YAML used in Symfony code, there are only one level parameters. That means you can use only the
payu parameter, nothing nested.
That's why all parameters have to be converted to the single level of nesting, here to
parameters: - payu: - user: Pepa + payu_user: Pepa - password: abz123 + payu_password: abz123 services: PayuService: arguments: - - '%payu.user%' + - '%payu_user%' - - '%payu.password%' + - '%payu_password%'
Another case are Neon entities. Their goal is to make syntax short. Its cost is less readability.
Code is actually parsed to an object, that has different meaning in different places:
services: - - App\SomeService(@anotherService, %perex%) + App\SomeService: + arguments: + - @anotherService + - %perex%
Those of you who don't use Neon for years, would you guess that?
All this converter handles for you.
Next time you migrate your config, package or whole application from Neon to YAML, let Symplify\NeonToYamlConverter do the work for you.