{"id":17623602,"url":"https://github.com/m1/vars","last_synced_at":"2025-04-13T06:37:38.088Z","repository":{"id":60774577,"uuid":"47557302","full_name":"m1/Vars","owner":"m1","description":"Vars is a simple to use and easily extendable configuration file loader for PHP with built-in support for env, INI, JSON, PHP, Toml, XML and YAML config file types. Contains a service provider for Silex, more frameworks to come soon.","archived":false,"fork":false,"pushed_at":"2022-11-16T10:32:41.000Z","size":123,"stargazers_count":64,"open_issues_count":9,"forks_count":12,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-10-29T23:17:25.845Z","etag":null,"topics":["php","php-config","php-config-parser","php-configuration","php-library","php-package"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/m1.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-07T14:34:07.000Z","updated_at":"2023-08-03T11:35:09.000Z","dependencies_parsed_at":"2023-01-23T10:31:33.812Z","dependency_job_id":null,"html_url":"https://github.com/m1/Vars","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1%2FVars","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1%2FVars/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1%2FVars/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1%2FVars/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/m1","download_url":"https://codeload.github.com/m1/Vars/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248675355,"owners_count":21143763,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","php-config","php-config-parser","php-configuration","php-library","php-package"],"created_at":"2024-10-22T21:11:17.053Z","updated_at":"2025-04-13T06:37:38.048Z","avatar_url":"https://github.com/m1.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vars\n\n[![Author](http://img.shields.io/badge/author-@milescroxford-blue.svg?style=flat-square)](https://twitter.com/milescroxford)\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status][ico-travis]][link-travis]\n[![Coverage Status][ico-scrutinizer]][link-scrutinizer]\n[![Quality Score][ico-code-quality]][link-code-quality]\n[![Total Downloads][ico-downloads]][link-downloads]\n\nVars is a simple to use, lightweight and easily extendable configuration loader with built-in loaders for ENV, INI, JSON, PHP, Toml, XML and YAML file types. It also comes built-in support for Silex with more frameworks (Symfony, Laravel etc) to come soon.\n\n* [Why?](#why)\n* [Requirements](#requirements)\n* [Install](#install)\n* [Usage](#usage)\n    * [Basic](#basic)\n    * [Accessing the config](#accessing-the-config)\n    * [Importing](#importing)\n        * [Files](#importing-files)\n        * [Directories](#importing-directories)\n        * [Flag options](#flag-options)\n    * [Resources](#resources)\n    * [Options](#options)\n        * [Path](#base-path)\n        * [Variables](#variables)\n            * [Replacement Variables](#replacements-variables)\n            * [In-file Variables](#in-file-variables)\n            * [Environment Variables](#environment-variables)\n        * [Caching](#caching)\n        * [Loaders](#loaders)\n    * [Providers](#providers)\n        * [Silex](#silex)\n    * [Public API](#public-api)\n        * [Vars](#vars-1)\n            * [Constructor](#varsresource-options--array)\n            * [getContent](#getcontent)\n            * [getResource](#getresourceresource)\n            * [getResources](#getresources)\n            * [toEnv](#toenv)\n            * [toDots](#todots)\n            * [set](#setkey-value)\n            * [get](#getkey)\n        * [FileResource](#fileresource)\n            * [getRawContent](#getrawcontent)\n            * [getContent](#getcontent-1)\n            * [get](#getkey-1)\n* [Todo](#todo)\n* [Change log](#change-log)\n* [Testing](#testing)\n* [Contributing](#Contributing)\n* [Security](#security)\n* [Credits](#credits)\n* [License](#license)\n\n## Why?\n\nSometimes you're forced to use different formats for config files and one of Vars aims is to make this simpler for you\nby supporting the most common config formats so you don't have to switch libraries to deal with the different formats.\n\nAnother aim is to support different frameworks so again you don't have to switch libraries when dealing with different frameworks.\nCurrently only supporting Silex using a service provider, support for Laravel and Symfony to follow shortly.\n\nWith a simple API and intuitive loading options, Vars tries to make config loading and providing as easy as possible for you.\n\n## Requirements\n\nVars requires PHP version `5.3+`.\n\nIf you want to use YAML you'll need the [`symfony/yaml`](https://github.com/symfony/yaml) library and similarly you'll need [`yosymfony/toml`](https://github.com/yosymfony/toml) to use Toml files and [`m1/env`](https://github.com/m1/env) to use Env files.\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require m1/vars\n```\n\n## Usage\n### Basic\n\n``` php\n// load single file\n$vars = new Vars(__DIR__.'/config/config.yml');\n\n// load from dir\n$vars = new Vars(__DIR__.'/config');\n\n// load from array\n$vars = new Vars(array(\n    __DIR__.'/config/config.yml',\n    __DIR__.'/config/sub',\n));\n```\n\n### Accessing the config\n\nThis can be done in various ways, you can treat the `$vars` variable as a normal array or you can use it in a object oriented manner\n\n``` php\n// All return the same thing\n$vars-\u003eget('db.password')\n$vars['db.password'];\n$vars['db']['password']\n```\n\nYou can also set values in the same manner\n\n``` php\n// All do the same thing\n$vars-\u003eset('db.password', 'test')\n$vars['db.password'] = 'test';\n$vars['db']['password'] = 'test';\n```\n\nYou can also get the variables from `getenv()`\n``` php\n// All do the same thing\n$vars-\u003etoEnv();\ngetenv('db.password');\n```\nFor more info on this check the [Environment Variables](#Environment-Variables) section\n\n### Importing\n\n#### Importing files\nYou can easily relatively and absolutely import configs into other configs, these differ by the config file type so check the /tests/mocks/ folder for examples\n\n``` yml\n# example_1.yml\ntest_key_1: test_value_1\nimports: example_2.yml\n\n# example_2.yml\ntest_key_2: test_value_2\n```\n\nWould return:\n``` php\n[\n    \"test_key_1\" =\u003e \"test_value_1\",\n    \"test_key_2\" =\u003e \"test_value_2\"\n]\n```\n\nImports are imported relative to the key by default, eg:\n\n``` yml\ntest_key_1:\n    imports: example_2.yml\n```\n\nWould return:\n``` php\n[\n    \"test_key_1\" =\u003e [\n        \"test_key_2\" =\u003e \"test_value_2\"\n    ]\n]\n```\n\nHowever you can change this various ways:\n``` yml\n# example 1\ntest_key_1:\n    imports: \n    - {resource: example.yml, relative: false}\n\n# example 2\ntest_key_2:\n    imports:\n        resource: example.yml\n        relative: false\n```\n\nIf importing various files and you want to set the relativity of all files you can do the following:\n``` yml\ntest_key_1:\n    imports: \n        relative: false\n        resource:\n            - example_2.yml\n            - example_3.yml\n```\n\nAll the above cause the `example_2.yml` and `example_3.yml` variables to become absolute to the config file:\n\n``` php\n[\n    \"test_key_1\" =\u003e []\n    \"test_key_2\" =\u003e \"test_value_2\" // from example_2.yml\n    \"test_key_3\" =\u003e \"test_value_3\" // from example_3.yml\n]\n```\n\n#### Importing directories\n\nYou can also import directories using all of the above syntax:\n``` yml\ntest_key_1:\n    imports: sub/\n```\n\nImporting directories is by default not recursive and will not search folders within folders, you can change this by adding a recursive toggle:\n``` yml\ntest_key_1:\n    imports:\n        resource: sub/\n        recursive: true\n```\n\nor by adding a recursive flag:\n``` yml\ntest_key_1:\n    imports:\n        resource: sub/*\n```\n\nAs with the loading files, you can bulk import dirs with one recursive toggle:\n``` yml\ntest_key_1:\n    imports:\n        recursive: false\n        resource:\n            - sub/\n            - sub1/\n```\n\nThe importing of directories relies on loaders and the extensions supported by the loaders. See the loader section for more detail.\n\n#### Flag options\n\nYou can use various flags when importing.\n\nThe if else flag `?:` makes it so if the first file exists, use that -- else use the other defined file, eg:\n\n```yml\nimports: \"example_1.yml ?: example_2.yml\"\n```\n\n*Note: You need to wrap the string in quotes for the if else flag to work*\n\nThe suppress exceptions flag `@` -- suppresses files not found exceptions. eg:\n\n```yml\nimports: @file_does_not_exist.yml\n```\n\nThe recursive flag makes it so directories within directories are searched for files. eg:\n``` yml\nimports:\n    resource: sub/*\n```\n\nYou can also combine the above flags, so if the else file option does not exist, it won't throw an exception, eg:\n\n```yml\nimports: \"example_1.yml ?: @example_2.yml\"\n```\n\n### Resources\n\nYou can get individual files or resources:\n\n``` php\n// All return the same thing\n$vars-\u003egetResource('example_2.yml')-\u003eget('test_key_2');\n$vars-\u003egetResource('example_2.yml')['test_key_2'];\n```\n\n### Options\n\nThere are various options for Vars\n\n``` php\n$vars = new Vars(__DIR__.'/config/config.yml', [\n    // this will affect how you getResource() and will  default to the path\n    // of the first resource you initiate\n    'path' =\u003e __DIR__.'/config',\n\n    // to cache or not -- defaults to true\n    'cache' =\u003e true,\n\n    // where the cache is stored -- If not set will default to the base path\n    'cache_path' =\u003e __DIR__.'/config/',\n\n    // How long the cache lasts for -- Defaults to 300 seconds (5 minutes)\n    'cache_expire' =\u003e 300,\n\n    // Replacement variables -- see variables section for more detail\n    'replacements' =\u003e [\n        'foo' =\u003e 'bar',\n        'foobar' =\u003e 'barfoo'\n    ],\n    \n    // Merge globals -- see globals section for more detail\n    'merge_globals' =\u003e true,\n\n    // The file loaders to load the configs -- see loader section for more detail\n    'loaders' =\u003e [\n        'default'\n    ]\n]);\n```\n\n#### Base path\n\nThe `path` is how the `$filename` in `$vars-\u003egetResource($filename)` is calculated. For example:\n\nIf you set the `path` to `__DIR__.'/config'` and you imported `__DIR__.'/app/test_1.yml'`:\n``` yml\n# example_1.yml\nimports: example_2.yml\n```\n\nThen both the `example_1.yml` and `example_2.yml` `$filename` would be `../app/test_1.yml` and `../app/test_1.yml` respectively.\n\nIf no `path` is set then the first file resource path will be used as the `path`, eg:\n\n``` php\n// example 1\n$vars = new Vars(__DIR__.'/config/config.yml');\n\n// example 2\n$vars = new Vars([\n    __DIR__.'/config/config.yml',\n    __DIR__.'/sub/config.yml',\n    ]);\n```\n\nWill both use `__DIR__.'/config'` as the `path`\n\n#### Variables\n\nYou can use 3 types of variables in `Vars`: `Replacements`, `In-file` and `Environment`, the syntax is:\n\n| Variable Type  | Syntax |\n| ------------- | ------------- |\n| Replacements  | `%VARIABLE%`  |\n| In-file | `%$VARIABLE%`  |\n| Environment | `%^VARIABLE%`  |\n\nFor better readability you can also put spaces between the variable name and the prefix/suffixes like so:\n```yml\nreplacement_variable: % VARIABLE %\ninfile_variable: %$ VARIABLE %\nenv_variable: %^ VARIABLE %\n```\n\n##### Replacements\n\nReplacement variables are loaded from outside `Vars`, so it's often used for `PHP` functions/logic, such as `__dir__`: \n``` yml\ntest_key_1: %foo%\ntest_key_2: /bar/%foobar%/bar\n```\n\n``` php\n$vars = new Vars(__DIR__.'/config/config.yml', [\n    'replacements' =\u003e [\n        'foo' =\u003e 'bar',\n        'foobar' =\u003e 'barfoo'\n    ],\n]);\n```\n\nOutputs:\n``` php\n[\n    \"test_key_1\" =\u003e \"bar\",\n    \"test_key_2\" =\u003e \"/bar/barfoo/foobar/\"\n]\n```\n\nYour replacements must be prefix and suffixed with `%`\n\nYou can also load variables from files:\n``` php\n$vars = new Vars(__DIR__.'/config/config.yml', [\n    'replacements' =\u003e __DIR__.'/config/variables.yml'\n]);\n```\n\n##### In-file Variables\n\nYou can also use variables from your already defined keys in the files, such as:\n``` yml\ntest_key_1: hello\ntest_key_2: /bar/%$test_key_1%/bar\n```\n\nOutputs:\n``` php\n[\n    \"test_key_1\" =\u003e \"bar\",\n    \"test_key_2\" =\u003e \"/bar/hello/foobar/\"\n]\n```\n\nYour replacements must be prefix with `%$` and suffixed with `%`.\n\nFor both `in-file` and `replacements`, you can use the dot notation syntax to get in arrays, e.g:\n``` yml\ntest_key_1: \n    test_key_2: hello\ntest_key_3: /bar/%$test_key_1.test_key_2%/bar\n```\n\nOutputs:\n``` php\n[\n    \"test_key_1\" =\u003e array(\n        \"test_key_2\" =\u003e \"hello\"\n    ),\n    \"test_key_2\" =\u003e \"/bar/hello/foobar/\"\n]\n```\n\n##### Environment Variables\n\nYou can also use environment variables to do replacements:\n\n``` yml\ntest_key_1: %^DATABASE_USERNAME%\ntest_key_2: %^DATABASE_PASSWORD%\n```\n\n``` nginx\n# nginx config example\nlocation @site {\n    fastcgi_pass unix:/var/run/php5-fpm.sock;\n    include fastcgi_params;\n    fastcgi_param  SCRIPT_FILENAME $document_root/index.php;\n\n    # env variables\n    fastcgi_param DATABASE_USERNAME test_username;\n    fastcgi_param DATABASE_PASSWORD test_password;\n}\n```\n\nOutputs:\n``` php\n[\n    \"test_key_1\" =\u003e \"test_username\",\n    \"test_key_2\" =\u003e \"test_password\"\n]\n```\n\nYour environment variables must be prefix with `%^` and suffixed with `%`\n\nYou can also make it so your config array is available to `getenv()`:\n\n```php\n$vars = new Vars(__DIR__.'/config/config.yml');\n$vars-\u003etoEnv();\n```\n\n*Note:* Your config will be flattened to a dot notation for this, e.g.:\n\n```yaml\ntest_key_1:\n    test_key_2: value\n```\n\nWill be accessed by:\n```php\ngetenv('test_key_1.test_key_2'); // value\n```\n\n#### Globals\n\n`Globals` in `Vars` refer to variables defined as such:\n\n```yaml\n_globals:\n    test_key_1: test_value_1\n```\n\nBasically they are just encapsulated in an `_globals` array -- the use of these are so you can access them from `getGlobals()` from `Vars`\n\nThe default action is to merge them into the other file contents, so that:\n\n```yaml\n_globals:\n    test_key_1: test_value_1\ntest_key_2: test_value_2\n```\n\nBecomes:\n```php\n[\n    'test_key_1' =\u003e 'test_value_1',\n    'test_key_2' =\u003e 'test_value_2',\n]\n```\nBut you can override this by changing `merge_globals` to `false` via the options.\n\nIf this doesn't make sense then you probably won't need to use globals at all, but they're useful for working with framesworks\nwhich encapsulate everything under say `$app` and you want to be able to access some key =\u003e values like so: `$app['test_key_1']`. \nSee the Silex provider section for more examples.\n\n#### Caching\n\nVars automatically caches the resources for 5 minutes, you can turn this off by setting the `cache` option to `false`.\n\nThe `cache_path` if not set is set to what the `path` is set to. The `cache_path` must be writeable.\n\nTo invalidate the cache, simply just remove the folder inside your `cache_path` called `vars`, eg: `rm -rf /var/www/application/app/cache/vars`\n\nThe cache file is a .php file due to the extra speedup of opcache.\n\nIf you're using the Silex provider, then the cache will not be used and set if you're in debug mode.\n\n#### Loaders\n\nThe loaders are what enable Vars to read the different file types (defaults are Ini, Json, Php, Toml, Xml and Yaml).\n\nYou can enable and disable loaders via the options:\n\nDefault loads all the default loaders:\n``` php\n$vars = new Vars(__DIR__.'/config/config.yml', [\n    'loaders' =\u003e 'default'\n]);\n\n// You can load individual loaders:\n$vars = new Vars(__DIR__.'/config/config.yml', [\n    'loaders' =\u003e [\n        'ini',\n        'json'\n    [\n]);\n\n//You can also create and load custom loaders:\n$vars = new Vars(__DIR__.'/config/config.yml', [\n    'loaders' =\u003e [\n        '\\Foo\\Bar\\CustomFooBarLoader',\n        'ini',\n        'json'\n    ]\n]);\n```\nTo create your own custom loader you must extend `M1\\Vars\\Loader\\AbstractLoader`, have the supported extensions in the\n`public static $supported` array and have a `public function load()` that loads the content of the file.\n\nHere is a primitive example that loads .txt files:\n\n```php\nnamespace M1\\Foo\\Bar\\Loader;\n\nuse M1\\Vars\\Loader\\AbstractLoader;\n\nclass TextLoader extends AbstractLoader\n{\n    public static $supported = array('txt');\n\n    public function load()\n    {\n\n        $content = [];\n\n        foreach (file($this-\u003eentity) as $line) {\n            list($key, $value) = explode(':', $line, 2);\n            $content[trim($key)] = trim($value);\n        }\n\n        $this-\u003econtent = $content;\n\n        return $this;\n    }\n}\n```\n\nThen to use this loader, you would simply use:\n```php\n$vars = new Vars(__DIR__.'/config/config.yml', [\n    'loaders' =\u003e [\n        '\\M1\\Foo\\Bar\\Loader\\TextLoader',\n    ]\n]);\n```\n\n*Note: don't use this loader for real, it is purely for presentational purposes*\n\n### Providers\n\n#### Silex\n\nIt's pretty straightforward to use this library with Silex, just register it when you register other service providers:\n```php\n$app-\u003eregister(new M1\\Vars\\Provider\\Silex\\VarsServiceProvider('example.yml'), [\n    'vars.path' =\u003e __DIR__.'/../../app/config/test/',\n    'vars.options' =\u003e [\n        'cache' =\u003e true,\n        'cache_path' =\u003e __DIR__.'/../../app/config/cache/',\n        'cache_expire' =\u003e 500,\n        'replacements' =\u003e [\n            'test' =\u003e 'test_replacement'\n        ],\n        'loaders' =\u003e [\n            'yml',\n            'json'\n        ],\n        'merge_globals' =\u003e true,\n        'replacements' =\u003e __DIR__.'/../../app/config/replacements.json',\n    ]]);\n```\n\nThen you can access your config from `$app['vars']`\n\n*Note: If you `$app['debug'] = true` then the cache will not be used.*\n\nYou can also access the config values from $app by using the dot notation, e.g:\n```yaml\ntest_key_1:\n    test_key_2: value\ntest_key_3: value\n```\n\nYou can get the above using the dot notation like so:\n```php\n$app['vars']['test_key_1.test_key_2']; // value\n$app['vars']['test_key_3']; // value\n```\n\nYou can also merge globals into `$app` like so:\n\n```yaml\n# example.yml\n_globals:\n    monolog.logfile: log.log\ntest_key_1: test_value_2\n```\n\n```php\n$app-\u003eregister(new M1\\Vars\\Provider\\Silex\\VarsServiceProvider('example.yml'));\n\n// register monolog here and other service providers\n\n$app['vars.merge']();\n```\n\nNote the `$app['vars.merge']()` -- This overrides the service provider defaults so in this example `monolog` will use \nthe log file defined in the vars config.\n\nYou must call `vars.merge` after you've called the service providers you provide config values for in your config.\n\nYou can also access `test_key_1` via `$app['vars.test_key_1']` and similary if you want, you can access globals like so\n`$app['monolog.logfile']`.\n\n## Public API\n\n### Vars\n\n##### `Vars($resource, $options = array())`\n\nThe constructor to create a new Vars config:\n\n``` php\n$vars = new Vars(__DIR__.'/config/config.yml', [\n    // this will affect how you getResource() and will  default to the path\n    // of the first resource you initiate\n    'path' =\u003e __DIR__.'/config',\n\n    // to cache or not -- defaults to true\n    'cache' =\u003e true,\n\n    // where the cache is stored -- If not set will default to the base path\n    'cache_path' =\u003e __DIR__.'/config/',\n\n    // How long the cache lasts for -- Defaults to 300 seconds (5 minutes)\n    'cache_expire' =\u003e 300,\n\n    // Replacement variables -- see variables section for more detail\n    'replacements' =\u003e [\n        'foo' =\u003e 'bar',\n        'foobar' =\u003e 'barfoo'\n    ],\n\n    // The file loaders to load the configs -- see loader section for more detail\n    'loaders' =\u003e [\n        'default'\n    ]\n]);\n```\n\n##### `getContent()`\n\nReturns the parsed content of all the configs.\n\n\n##### `getResource($resource)`\n\nGet a specified resource, returns a file resource or false if resource doesn't exist.\n\nThe `$resource` name is based on the path defined in base path and the filename.\n\n```yml\n# example.yml\nimports: example2.yml\ntest_1: value\n\n# example2.yml\ntest_2: value\n```\n\n```php\n$vars = new Vars('example.yml');\n$vars-\u003egetResource('example2.yml'); // FileResource\n\n$vars-\u003egetResource('example2.yml')-\u003egetContent();\n# output:\n# [\n#     \"test_2\" =\u003e \"value\"\n# ]\n```\n\n\n##### `getResources()`\n\nReturns all the resources imported, they will be `FileResource` objects.\n\n\n##### `toEnv()`\n\nMakes it so the config is available via `getenv()`:\n\n```php\n$vars = new Vars('example.yml');\n$vars-\u003etoEnv();\n\ngetenv('test_1'); // value\n\n```\n\n\n##### `toDots()`\n\nMakes it so the config is flattened into a dot notation array\n\n```yml\ntest_value_1:\n    test_value_2: value\n    test_value_3: value\n```\n\n```php\n$vars = new Vars('example.yml');\n$vars-\u003etoDots();\n# output:\n# [\n#     \"test_value_1.test_value_2\" =\u003e \"value\",\n#     \"test_value_1.test_value_3\" =\u003e \"value\n# ]\n```\n\n##### `getGlobals()`\n\nGets the values defined in `_globals`\n\n##### `set($key, $value)`\nSet a config key:\n\n```php\n$vars = new Vars('example.yml');\n$vars-\u003eset('test_key_1', 'value_2');\n```\n\n\n##### `get($key)`\nGets a config key:\n\n```php\n$vars = new Vars('example.yml');\n$vars-\u003eget('test_key_1'); // value\n```\n\n\n### FileResource\n\n\n##### `getRawContent()`\n\nGet the raw, unparsed content from the file\n\n```yml\n# example.yml\ntest_value_1:\n    imports: example2.yml\ntest_value_2: %root%/foo/%dir%\n```\n\n```php\n$vars = new Vars('example.yml');\n$vars-\u003egetResource('example.yml')-\u003egetRawContent();\n# output:\n# [\n#     test_value_1:\n#          imports: example2.yml\n#     test_value_2: %root%/foo/%dir%\n# ]\n```\n\n\n##### `getContent()`\nSee [getContent()](#getcontent) \n\n\n##### `get($key)`\nSee [get()](#getkey)\n\n\n## Todo\n\n- Add more providers (Symfony, Laravel, etc)\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email hello@milescroxford.com instead of using the issue tracker.\n\n## Credits\n\n- [m1](http://github.com/m1)\n- [All Contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/m1/Vars.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/m1/Vars/master.svg?style=flat-square\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/m1/Vars.svg?style=flat-square\n[ico-code-quality]: https://img.shields.io/scrutinizer/g/m1/Vars.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/m1/Vars.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/m1/Vars\n[link-travis]: https://travis-ci.org/m1/Vars\n[link-scrutinizer]: https://scrutinizer-ci.com/g/m1/Vars/code-structure\n[link-code-quality]: https://scrutinizer-ci.com/g/m1/Vars\n[link-downloads]: https://packagist.org/packages/m1/Vars\n[link-author]: https://github.com/m1\n[link-contributors]: ../../contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm1%2Fvars","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm1%2Fvars","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm1%2Fvars/lists"}