Skip to content
develop
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 

README.md

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

License

Releases

No releases published

Packages

No packages published

Languages

You can’t perform that action at this time.