<?php session_start(); \Slim\Slim::registerAutoloader(); $app = new \SlimController\Slim(array('templates.path' => dirname(__DIR__) . '/views/', 'cookies.secret_key' => md5('appsecretkey'), 'controller.class_prefix' => '', 'controller.method_suffix' => '', 'controller.template_suffix' => 'twig', 'mode' => 'production', 'debug' => true)); if ($app->config('debug') === true) { ini_set('display_errors', 'On'); error_reporting(E_ALL); $app->add(new \Zeuxisoo\Whoops\Provider\Slim\WhoopsMiddleware()); } /** Create monolog logger and store logger in container as singleton * (Singleton resources retrieve the same log resource definition each time) * $app->log->info("Log error"); * try catch hook * $app->applyHook('log.request.info', $e->getMessage()); * $app->log->error($e); */ $app->container->singleton('log', function () use($app) { $logpath = dirname(__DIR__) . '/logs/' . date('Y/m'); $logfile = $logpath . '/' . date('d') . '.log'; $old = umask(0); if (!is_dir($logpath)) { mkdir($logpath, 0777, true); } if (!is_writable($logpath)) { chmod($logfile, 0777); } if (!file_exists($logfile)) { file_put_contents($logfile, ''); } umask($old);
<?php define('APP_PATH', dirname(__DIR__)); require APP_PATH . '/vendor/autoload.php'; // load configuration $dotenv = new \Dotenv\Dotenv(APP_PATH); $dotenv->load(); $dotenv->required(['APP_DEBUG']); // define the app $app = new \SlimController\Slim(); // configure application $app->config(['templates.path' => APP_PATH . '/app/views', 'controller.class_prefix' => '\\app\\controllers', 'controller.class_suffix' => 'Controller', 'controller.method_suffix' => 'Action', 'view' => new \Slim\Views\Twig(), 'log.enabled' => true, 'log.level' => \Slim\Log::DEBUG, 'log.writer' => new \Slim\Logger\DateTimeFileWriter(['path' => APP_PATH . '/storage/logs'])]); // configure models require_once APP_PATH . '/vendor/j4mie/idiorm/idiorm.php'; require_once APP_PATH . '/vendor/j4mie/paris/paris.php'; ORM::configure('mysql:host=' . getenv('DB_HOST') . ';dbname=' . getenv('DB_NAME')); ORM::configure('username', getenv('DB_USERNAME')); ORM::configure('password', getenv('DB_PASSWORD')); Model::$auto_prefix_models = '\\app\\models\\'; // configure views $app->view()->parserOptions = ['debug' => true, 'cache' => APP_PATH . '/storage/twig']; $app->view()->parserExtensions = [new \Slim\Views\TwigExtension(), new \src\twig\TwigExtension()]; // environment depending settings if (getenv('APP_DEBUG') == 'true') { // configure logging $app->config('debug', true); // configure request logging $app->hook('slim.after.router', function () use($app) { $request = $app->request; $response = $app->response; $app->log->debug(sprintf('Request path: %s - Response status: %d', $request->getPathInfo(), $response->getStatus()));
<?php ref::config('showPrivateMembers', true); ref::config('expLvl', 3); ref::config('showUrls', false); // init app $app = new \SlimController\Slim(array('templates.path' => dirname(__DIR__) . '/views', 'cookies.secret_key' => md5('appsecretkey'), 'controller.class_suffix' => '', 'controller.method_suffix' => '', 'controller.template_suffix' => 'twig', 'mode' => 'production', 'debug' => true)); if ($app->config('debug') === true) { ini_set('display_errors', 'On'); error_reporting(E_ALL); $app->config('whoops.editor', 'sublime'); $app->add(new \Zeuxisoo\Whoops\Provider\Slim\WhoopsMiddleware()); } /** Create monolog logger and store logger in container as singleton * (Singleton resources retrieve the same log resource definition each time) * $app->log->info("Log error"); * try catch hook * $app->applyHook('log.request.info', $e->getMessage()); * $app->log->error($e); */ $app->container->singleton('log', function () use($app) { $logpath = APP_PATH . '/app/logs/' . date('Y/m'); $logfile = $logpath . '/' . date('d') . '.log'; $old = umask(0); if (!is_dir($logpath)) { mkdir($logpath, 0777, true); } if (!is_writable($logpath)) { chmod($logfile, 0777); } if (!file_exists($logfile)) {