Esempio n. 1
0
 /**
  * Registra el servicio
  *
  * @param Api $app Instancia de la aplicacion
  *
  * @return void
  */
 public static function register(Api $app)
 {
     $container = $app->getContainer();
     $loggerConfig = $container->get('loggy');
     $loggers = new LoggerCollection();
     foreach ($loggerConfig as $channel => $channelConfig) {
         $handlers = [];
         foreach ($channelConfig as $handlerConfig) {
             extract($handlerConfig);
             $handlers[] = (new $handler($level))->config($config);
         }
         $loggers->set($channel, new Logger($channel, $handlers));
     }
     $container['logger'] = $loggers;
 }
Esempio n. 2
0
 /**
  * Registra el servicio
  *
  * @param Api $app Instancia de la aplicacion
  *
  * @return void
  */
 public static function register(Api $app)
 {
     $container = $app->getContainer();
     $loggerConfig = $container->get('monolog');
     $loggers = new LoggerCollection();
     foreach ($loggerConfig as $channel => $channelConfig) {
         $logger = new Logger($channel);
         foreach ($channelConfig as $handlerConfig) {
             extract($handlerConfig);
             $logger->pushHandler(new $handler($config['output'], $level));
         }
         $loggers->set($channel, $logger);
     }
     $container['logger'] = $loggers;
 }
Esempio n. 3
0
<?php

/**
 * Index
 *
 * PHP version 7+
 *
 * Copyright (c) 2016 Federico Lozada Mosto <*****@*****.**>
 * For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
 *
 * @category  RestySkeleton
 * @package   RestySkeleton
 * @author    Federico Lozada Mosto <*****@*****.**>
 * @copyright 2016 Federico Lozada Mosto <*****@*****.**>
 * @license   MIT License (http://www.opensource.org/licenses/mit-license.php)
 * @link      http://www.mostofreddy.com.ar
 */
$path = realpath(__DIR__ . '/../');
require $path . "/vendor/autoload.php";
use Resty\Api;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
$configFilePath = realpath(__DIR__ . "/../config/") . '/config.php';
$config = (include_once $configFilePath);
$app = new Api($config);
$app->get('/', '\\Resty\\Api\\Welcome\\IndexController');
$app->run();
Esempio n. 4
0
<?php

/**
 * Index
 *
 * PHP version 7+
 *
 * Copyright (c) 2016 Federico Lozada Mosto <*****@*****.**>
 * For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
 *
 * @category  Modulus
 * @package   Modulus\Example
 * @author    Federico Lozada Mosto <*****@*****.**>
 * @copyright 2016 Federico Lozada Mosto <*****@*****.**>
 * @license   MIT License (http://www.opensource.org/licenses/mit-license.php)
 * @link      http://www.mostofreddy.com.ar
 */
$path = realpath(__DIR__ . '/../');
require $path . "/vendor/autoload.php";
use Resty\Api;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
$configFilePath = realpath(__DIR__ . '/../config/config.php');
$config = (include_once $configFilePath);
$app = new Api($config);
$app->get('/', function (Request $req, Response $res) {
    return $res->withJson("Hello world!", 200);
});
// run App
$app->run();