Skip to content
Devin Smith edited this page Feb 3, 2016 · 13 revisions

Tipsy accesses much of its configuration from a single config object

Accessing config

Base object

var_dump($tipsy->config());

Database hostname

echo $tipsy->config()['db']['host'];

Setting the config

You can set the config in a config file, multiple config files, or at any point during execution.

Execution

$tipsy->config(['view' => [
	'path' => 'views',
	'layout' => 'awesome-layout'
]]);

Include Files

Tipsy supports both INI and YAML file formats. YML parsing requires a yml parsing library. You can install one using symfony/yaml from Packagist, or the yaml_parse_file function using PECL.

// Tell tipsy to read the config files
$tipsy->config('production.ini');
$tipsy->config('plugins.yml');

// use wildcard selectors
$tipsy->config('config/*.ini');
$tipsy->config('config/*.yml');
$tipsy->config('config/*');

Example configs

You can combine both INI and YML and it will Recursive Replace the config arrays.

In

db:
  user: username
  pass: password
  driver: mysql

view:
  path: views
[db]
host=localhost

[view]
layout=default

Out

{
  "db": {
    "user": "username",
    "pass": "password",
    "driver": "mysql",
    "host": "localhost"
  },
  "view": {
    "path": "views",
    "layout": "default"
  }
}