Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate configuration from code (yaml|json|xml) #5

Open
dnaber-de opened this issue May 18, 2016 · 0 comments
Open

Separate configuration from code (yaml|json|xml) #5

dnaber-de opened this issue May 18, 2016 · 0 comments

Comments

@dnaber-de
Copy link
Owner

dnaber-de commented May 18, 2016

Basically, every configuration can be combined into arrays:

<?php

$sites = [
    'root' => [
        'url' => 'http://mysite.org/',
        'title' => 'My Site'
    ],
    'shop' => [
        'url' => 'http://mysite.org/shop/',
        'title' => 'My Shop'
    ]
];

$user = [
    'admin' => [
        'login' => 'david',
        'email' => '[email protected]'
    ],
    'editor' => [
        'login' => 'john',
        'email' => '[email protected]'
    ]
];

$plugins = [
    'network' => [
        'multilingual-press',
        'elasticpress'
    ],
    'root' => [
        'buddypress'
    ],
    'shop' => [
        'woocommerce'
    ]
];

The logic is then often very similar: it just loops over the entities and run the corresponding WP command.

Thus a configuration file would make sense here to avoid repetitive implementations of invoking this commands.

For the format I would prefer YAML over JSON even though, JSON has the more flexible syntax, because YAML allows comments.

Example:

sites:
  root:
    url: http://mysite.org/
    title: My Site
  shop:
    # ...

users:
  admin: 
    login: david
    email: [email protected]
  editor:
    # ...

# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant