Updated to Symplify package.
I wrote about How to migrate between Neon to Yaml almost a year ago. Recently we needed to migrate many files with parameters, imports, and mainly services.
Neon and YAML are basically arrays, right? So why not let a tool let do the dirty work?
To use symplify/neon-to-yaml-converter, 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/neon-to-yaml-conveter do the work for you.