Skip to content

Instantly share code, notes, and snippets.

@thiagophx
Created December 20, 2011 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiagophx/1501488 to your computer and use it in GitHub Desktop.
Save thiagophx/1501488 to your computer and use it in GitHub Desktop.
Dependency Injection on .ini Files
; services.ini
[userService MyApp\Service\UserService]
options = [appContainer]
serviceLocator = [this]
; application.ini
; App configuration
url = "http://www.google.com"
db_host = "127.0.0.1"
dados = [[url], [db_host]]
appConfig = SETTINGS_PATH
[serviceLocator Respect\Config\Container]
appContainer = [dados]
loadFile[] = "[appConfig]services.ini"
<?php
$c = new Respect\Config\Container(SETTINGS_PATH . 'application.ini');
var_dump($c->serviceLocator->userService);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment