Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Distributed YAML

This library is NOT intended to be used in production or taken seriously. It's just an idea I had to use as an example for working with custom YAML tags introduced in Symfony 3.3 and the associated TaggedValue class.

Example Usage

# config/doctrine.yaml

doctrine:
    dbal:
        driver: 'pdo_mysql'
        url: '%env(resolve:DATABASE_URL)%'
    orm:
        auto_mapping: true
        # This is the magic...
        mappings: !import "./doctrine/mappings.yaml"
# config/doctrine/mappings.yaml

App:
    is_bundle: false
    type: annotation
    dir: '%kernel.project_dir%/src/Entity'
    prefix: 'App\Entity'
    alias: App
<?php declare(strict_types=1);
use Darsyn\Yaml\DistributedYaml;
require_once __DIR__ . '/vendor/autoload.php';
$doctrineConfig = DistributedYaml::parseFile('config/doctrine.yaml');
echo json_encode($doctrineConfig, JSON_PRETTY_PRINT) . PHP_EOL;

The above PHP file will echo out the following JSON:

{
    "doctrine": {
        "dbal": {
            "driver": "pdo_mysql",
            "url": "%env(resolve:DATABASE_URL)%"
        },
        "orm": {
            "auto_mapping": true,
            "mappings": {
                "App": {
                    "is_bundle": false,
                    "type": "annotation",
                    "dir": "%kernel.project_dir%\/src\/Entity",
                    "prefix": "App\\Entity",
                    "alias": "App"
                }
            }
        }
    }
}

About

A decorator for Symfony's YAML component, allowing for distributed YAML configuration.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages