schranz-php-recipes / symfony-recipes-yaml-to-php-converter

A wrapper around symplify/config-transformer used to update recipes and using easy coding standard for generating readable config files.
MIT License
5 stars 0 forks source link

Keep / Convert Yaml comments to PHP #1

Open alexander-schranz opened 2 years ago

alexander-schranz commented 2 years ago

Currently the config-transformer is using the symfony/yaml package. Instead we should use a package which is supporting to read comments from yaml files as they provide many usefull things like links to documentation.

Yaml:

# Read the documentation at https://github.com/thephpleague/flysystem-bundle/blob/master/docs/1-getting-started.md
flysystem:
    storages:
        default.storage:
            adapter: 'local'
            options:
                directory: '%kernel.project_dir%/%VAR_DIR%/storage/default'

Expected PHP Result:

<?php

declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
    // Read the documentation at https://github.com/thephpleague/flysystem-bundle/blob/master/docs/1-getting-started.md
    $containerConfigurator->extension('flysystem', [
        'storages' => [
            'default.storage' => [
                'adapter' => 'local',
                'options' => [
                    'directory' => '%kernel.project_dir%/%VAR_DIR%/storage/default',
                ],
            ],
        ],
    ]);  
};

Currently the comment is missing which adds a lot of value.

Related issues:

weaverryan commented 2 years ago

I agree that this is important... but does such a YAML library exist? Or would someone need to hack together a script to "find the comments" then try to re-add them to the PHP after the fact?