2018-04-15 14:51:31 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use \Psr\Http\Message\ServerRequestInterface as Request;
|
|
|
|
use \Psr\Http\Message\ResponseInterface as Response;
|
|
|
|
|
2018-04-18 19:03:39 +02:00
|
|
|
use \Grocy\Helpers\UrlManager;
|
2018-04-19 20:44:49 +02:00
|
|
|
use \Grocy\Controllers\LoginController;
|
2018-04-15 14:51:31 +02:00
|
|
|
|
2018-07-25 19:28:15 +02:00
|
|
|
// Definitions for embedded mode
|
2018-07-16 21:17:32 +02:00
|
|
|
if (file_exists(__DIR__ . '/embedded.txt'))
|
|
|
|
{
|
2018-07-25 19:28:15 +02:00
|
|
|
define('GROCY_IS_EMBEDDED_INSTALL', true);
|
2018-07-24 19:41:35 +02:00
|
|
|
define('GROCY_DATAPATH', file_get_contents(__DIR__ . '/embedded.txt'));
|
2018-07-24 20:45:14 +02:00
|
|
|
define('GROCY_USER_ID', 1);
|
2018-07-16 21:17:32 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-07-25 19:28:15 +02:00
|
|
|
define('GROCY_IS_EMBEDDED_INSTALL', false);
|
2018-07-24 19:41:35 +02:00
|
|
|
define('GROCY_DATAPATH', __DIR__ . '/data');
|
2018-07-16 21:17:32 +02:00
|
|
|
}
|
|
|
|
|
2018-07-25 19:28:15 +02:00
|
|
|
// Definitions for demo mode
|
|
|
|
if (file_exists(GROCY_DATAPATH . '/demo.txt'))
|
|
|
|
{
|
|
|
|
define('GROCY_IS_DEMO_INSTALL', true);
|
|
|
|
if (!defined('GROCY_USER_ID'))
|
|
|
|
{
|
|
|
|
define('GROCY_USER_ID', 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
define('GROCY_IS_DEMO_INSTALL', false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load composer dependencies
|
2018-04-15 14:51:31 +02:00
|
|
|
require_once __DIR__ . '/vendor/autoload.php';
|
2018-07-25 19:28:15 +02:00
|
|
|
|
2018-08-04 07:45:24 +02:00
|
|
|
// Load config files
|
2018-07-24 19:41:35 +02:00
|
|
|
require_once GROCY_DATAPATH . '/config.php';
|
2018-07-12 19:12:31 +02:00
|
|
|
require_once __DIR__ . '/config-dist.php'; //For not in own config defined values we use the default ones
|
2018-04-15 14:51:31 +02:00
|
|
|
|
|
|
|
// Setup base application
|
2018-04-19 20:44:49 +02:00
|
|
|
$appContainer = new \Slim\Container([
|
|
|
|
'settings' => [
|
|
|
|
'displayErrorDetails' => true,
|
|
|
|
'determineRouteBeforeAppMiddleware' => true
|
|
|
|
],
|
|
|
|
'view' => function($container)
|
|
|
|
{
|
2018-07-24 19:41:35 +02:00
|
|
|
return new \Slim\Views\Blade(__DIR__ . '/views', GROCY_DATAPATH . '/viewcache');
|
2018-04-19 20:44:49 +02:00
|
|
|
},
|
|
|
|
'LoginControllerInstance' => function($container)
|
|
|
|
{
|
|
|
|
return new LoginController($container, 'grocy_session');
|
|
|
|
},
|
|
|
|
'UrlManager' => function($container)
|
|
|
|
{
|
2018-07-24 19:41:35 +02:00
|
|
|
return new UrlManager(GROCY_BASE_URL);
|
2018-04-21 19:18:00 +02:00
|
|
|
},
|
|
|
|
'ApiKeyHeaderName' => function($container)
|
|
|
|
{
|
|
|
|
return 'GROCY-API-KEY';
|
2018-04-19 20:44:49 +02:00
|
|
|
}
|
|
|
|
]);
|
|
|
|
$app = new \Slim\App($appContainer);
|
|
|
|
|
2018-07-25 19:28:15 +02:00
|
|
|
// Load routes from separate file
|
2018-04-15 14:51:31 +02:00
|
|
|
require_once __DIR__ . '/routes.php';
|
|
|
|
|
|
|
|
$app->run();
|