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

Add support to read from string #108

Closed
filips123 opened this issue Jul 1, 2018 · 1 comment · Fixed by #111
Closed

Add support to read from string #108

filips123 opened this issue Jul 1, 2018 · 1 comment · Fixed by #111
Milestone

Comments

@filips123
Copy link
Collaborator

filips123 commented Jul 1, 2018

Add support for reading from strings and writing to strings instead of files. This could be done with methods fromString($format, $data) and toString($format, $data).

Note that the format parameter should be case insensitive.

Example of reading:

$settings = <<<FOOBAR
{
  "application": {
    "name": "configuration",
    "secret": "s3cr3t"
  },
  "host": "localhost",
  "port": 80,
  "servers": [
    "host1",
    "host2",
    "host3"
  ]
}
FOOBAR;
$conf = Config::fromString('JSON', $json);

Example of writing:

$json = $conf->toString('JSON')
$conf->toString('YAML', $yaml);
@filips123
Copy link
Collaborator Author

I've created pull request #111 for loading from string.

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

Successfully merging a pull request may close this issue.

2 participants