Added Dependency Injection (DI) method from Symfony framework. Added ChromePhp logger and some dummy loggers. These signature is somewhat compatible to Monolog which Symfony uses. Added Config service skeleton - to be used via DI.
Signed-off-by: Markus Birth <mbirth@gmail.com>
This commit is contained in:
parent
d8dfe69821
commit
753997ea55
@ -5,7 +5,11 @@
|
||||
"php": ">=5.3.0",
|
||||
"ezyang/htmlpurifier": "4.5.0",
|
||||
"smarty/smarty": "2.6.26",
|
||||
"ocpl/okapi": "dev-master"
|
||||
"ocpl/okapi": "dev-master",
|
||||
"symfony/dependency-injection": "dev-master",
|
||||
"symfony/yaml": "dev-master",
|
||||
"symfony/config": "dev-master",
|
||||
"ccampbell/chromephp": "dev-master"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "": "lib/" },
|
||||
|
269
htdocs/composer.lock
generated
269
htdocs/composer.lock
generated
@ -3,8 +3,51 @@
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
|
||||
],
|
||||
"hash": "23be83efb6b4a5cca96f1f15c9625eb9",
|
||||
"hash": "480b83d0fda088d1cec81d930c5d4754",
|
||||
"packages": [
|
||||
{
|
||||
"name": "ccampbell/chromephp",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ccampbell/chromephp.git",
|
||||
"reference": "c3c297615d48ae5b2a86a82311152d1ed095fcef"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ccampbell/chromephp/zipball/c3c297615d48ae5b2a86a82311152d1ed095fcef",
|
||||
"reference": "c3c297615d48ae5b2a86a82311152d1ed095fcef",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.0.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"ChromePhp": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"Apache-2.0"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Craig Campbell",
|
||||
"email": "iamcraigcampbell@gmail.com",
|
||||
"homepage": "http://craig.is",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Log variables to the Chrome console (via Chrome Logger Google Chrome extension).",
|
||||
"homepage": "http://github.com/ccampbell/chromephp",
|
||||
"keywords": [
|
||||
"log",
|
||||
"logging"
|
||||
],
|
||||
"time": "2013-06-26 03:44:33"
|
||||
},
|
||||
{
|
||||
"name": "ezyang/htmlpurifier",
|
||||
"version": "v4.5.0",
|
||||
@ -50,6 +93,21 @@
|
||||
],
|
||||
"time": "2013-02-18 00:04:08"
|
||||
},
|
||||
{
|
||||
"name": "ocpl/okapi",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "svn",
|
||||
"url": "http://opencaching-api.googlecode.com/svn/",
|
||||
"reference": "trunk/okapi/"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"./"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "smarty/smarty",
|
||||
"version": "2.6.26",
|
||||
@ -70,6 +128,205 @@
|
||||
"libs/"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "symfony/config",
|
||||
"version": "dev-master",
|
||||
"target-dir": "Symfony/Component/Config",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Config.git",
|
||||
"reference": "bde2f7192a52dfd07cf5484ad65d719da28effba"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Config/zipball/bde2f7192a52dfd07cf5484ad65d719da28effba",
|
||||
"reference": "bde2f7192a52dfd07cf5484ad65d719da28effba",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"symfony/filesystem": "~2.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.5-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Symfony\\Component\\Config\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Config Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2014-01-07 13:29:57"
|
||||
},
|
||||
{
|
||||
"name": "symfony/dependency-injection",
|
||||
"version": "dev-master",
|
||||
"target-dir": "Symfony/Component/DependencyInjection",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/DependencyInjection.git",
|
||||
"reference": "26648a063db967e0a0510df14d22555f4afd898e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/26648a063db967e0a0510df14d22555f4afd898e",
|
||||
"reference": "26648a063db967e0a0510df14d22555f4afd898e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/config": "~2.2",
|
||||
"symfony/expression-language": "~2.4",
|
||||
"symfony/yaml": "~2.0"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/config": "",
|
||||
"symfony/proxy-manager-bridge": "Generate service proxies to lazy load them",
|
||||
"symfony/yaml": ""
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.5-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Symfony\\Component\\DependencyInjection\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony DependencyInjection Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2014-01-07 13:29:57"
|
||||
},
|
||||
{
|
||||
"name": "symfony/filesystem",
|
||||
"version": "v2.4.1",
|
||||
"target-dir": "Symfony/Component/Filesystem",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Filesystem.git",
|
||||
"reference": "b3c3b5a8108b3e5d604dc23241b4ea84a067fc78"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Filesystem/zipball/b3c3b5a8108b3e5d604dc23241b4ea84a067fc78",
|
||||
"reference": "b3c3b5a8108b3e5d604dc23241b4ea84a067fc78",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Symfony\\Component\\Filesystem\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Filesystem Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2013-12-31 13:43:26"
|
||||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"version": "dev-master",
|
||||
"target-dir": "Symfony/Component/Yaml",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Yaml.git",
|
||||
"reference": "9921872611710df49cf035c259e5a461ea2d0f8c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Yaml/zipball/9921872611710df49cf035c259e5a461ea2d0f8c",
|
||||
"reference": "9921872611710df49cf035c259e5a461ea2d0f8c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.5-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Symfony\\Component\\Yaml\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "http://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Yaml Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2014-01-07 13:29:57"
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
@ -79,9 +336,13 @@
|
||||
|
||||
],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [
|
||||
|
||||
],
|
||||
"stability-flags": {
|
||||
"ocpl/okapi": 20,
|
||||
"symfony/dependency-injection": 20,
|
||||
"symfony/yaml": 20,
|
||||
"symfony/config": 20,
|
||||
"ccampbell/chromephp": 20
|
||||
},
|
||||
"platform": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
|
11
htdocs/config/services.yml
Normal file
11
htdocs/config/services.yml
Normal file
@ -0,0 +1,11 @@
|
||||
parameters:
|
||||
ocde.config.class: OpencachingDE\Config\Config
|
||||
ocde.logging.class: OpencachingDE\Logging\ChromePhp
|
||||
|
||||
services:
|
||||
ocde.config:
|
||||
class: "%ocde.config.class%"
|
||||
|
||||
# Monolog/Symfony compatible name
|
||||
logger:
|
||||
class: "%ocde.logging.class%"
|
28
htdocs/lib/OpencachingDE/Config/Config.php
Normal file
28
htdocs/lib/OpencachingDE/Config/Config.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/****************************************************************************
|
||||
_ _ _
|
||||
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
|
||||
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
|
||||
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|
||||
|_| |___/
|
||||
|
||||
For license information see doc/license.txt --- Unicode Reminder メモ
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
namespace OpencachingDE\Config;
|
||||
|
||||
class Config
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$logger = $this->getContainer()->get('logger');
|
||||
$logger->debug('Hello world!');
|
||||
}
|
||||
|
||||
public function getContainer()
|
||||
{
|
||||
return $GLOBALS['container'];
|
||||
}
|
||||
}
|
20
htdocs/lib/OpencachingDE/Config/ConfigReader.php
Normal file
20
htdocs/lib/OpencachingDE/Config/ConfigReader.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/****************************************************************************
|
||||
_ _ _
|
||||
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
|
||||
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
|
||||
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|
||||
|_| |___/
|
||||
|
||||
For license information see doc/license.txt --- Unicode Reminder メモ
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
namespace OpencachingDE\Config;
|
||||
|
||||
class ConfigReader
|
||||
{
|
||||
|
||||
|
||||
}
|
58
htdocs/lib/OpencachingDE/Logging/ChromePhp.php
Normal file
58
htdocs/lib/OpencachingDE/Logging/ChromePhp.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/****************************************************************************
|
||||
_ _ _
|
||||
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
|
||||
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
|
||||
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|
||||
|_| |___/
|
||||
|
||||
For license information see doc/license.txt --- Unicode Reminder メモ
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
namespace OpencachingDE\Logging;
|
||||
|
||||
// Keep a loose Monolog compatibility to make it easier to replace it later
|
||||
|
||||
class ChromePhp
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function debug($message, array $context = array())
|
||||
{
|
||||
\ChromePhp::log($message);
|
||||
}
|
||||
|
||||
public function info($message, array $context = array())
|
||||
{
|
||||
\ChromePhp::info($message);
|
||||
}
|
||||
|
||||
public function notice($message, array $context = array())
|
||||
{
|
||||
\ChromePhp::info($message);
|
||||
}
|
||||
|
||||
public function warning($message, array $context = array())
|
||||
{
|
||||
\ChromePhp::warn($message);
|
||||
}
|
||||
|
||||
public function error($message, array $context = array())
|
||||
{
|
||||
\ChromePhp::error($message);
|
||||
}
|
||||
|
||||
public function critical($message, array $context = array())
|
||||
{
|
||||
\ChromePhp::error($message);
|
||||
}
|
||||
|
||||
public function emergency($message, array $context = array())
|
||||
{
|
||||
\ChromePhp::error($message);
|
||||
}
|
||||
}
|
56
htdocs/lib/OpencachingDE/Logging/File.php
Normal file
56
htdocs/lib/OpencachingDE/Logging/File.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/****************************************************************************
|
||||
_ _ _
|
||||
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
|
||||
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
|
||||
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|
||||
|_| |___/
|
||||
|
||||
For license information see doc/license.txt --- Unicode Reminder メモ
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
namespace OpencachingDE\Logging;
|
||||
|
||||
// Keep a loose Monolog compatibility to make it easier to replace it later
|
||||
|
||||
class File
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function debug($message, array $context = array())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function info($message, array $context = array())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function notice($message, array $context = array())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function warning($message, array $context = array())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function error($message, array $context = array())
|
||||
{
|
||||
}
|
||||
|
||||
public function critical($message, array $context = array())
|
||||
{
|
||||
}
|
||||
|
||||
public function emergency($message, array $context = array())
|
||||
{
|
||||
}
|
||||
}
|
51
htdocs/lib/OpencachingDE/Logging/Null.php
Normal file
51
htdocs/lib/OpencachingDE/Logging/Null.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/****************************************************************************
|
||||
_ _ _
|
||||
___ _ __ ___ _ _ __ __ _ __| |_ (_)_ _ __ _ __| |___
|
||||
/ _ \ '_ \/ -_) ' \/ _/ _` / _| ' \| | ' \/ _` |_/ _` / -_)
|
||||
\___/ .__/\___|_||_\__\__,_\__|_||_|_|_||_\__, (_)__,_\___|
|
||||
|_| |___/
|
||||
|
||||
For license information see doc/license.txt --- Unicode Reminder メモ
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
namespace OpencachingDE\Logging;
|
||||
|
||||
// Keep a loose Monolog compatibility to make it easier to replace it later
|
||||
|
||||
class Null
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function debug($message, array $context = array())
|
||||
{
|
||||
}
|
||||
|
||||
public function info($message, array $context = array())
|
||||
{
|
||||
}
|
||||
|
||||
public function notice($message, array $context = array())
|
||||
{
|
||||
}
|
||||
|
||||
public function warning($message, array $context = array())
|
||||
{
|
||||
}
|
||||
|
||||
public function error($message, array $context = array())
|
||||
{
|
||||
}
|
||||
|
||||
public function critical($message, array $context = array())
|
||||
{
|
||||
}
|
||||
|
||||
public function emergency($message, array $context = array())
|
||||
{
|
||||
}
|
||||
}
|
@ -12,3 +12,14 @@ For license information see doc/license.txt --- Unicode Reminder メモ
|
||||
****************************************************************************/
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../config/'));
|
||||
$loader->load('services.yml');
|
||||
// $loader->load('anotherfile.yml');
|
||||
|
||||
$config = $container->get('ocde.config');
|
||||
|
Loading…
x
Reference in New Issue
Block a user