forked from forkcms/forkcms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
68 lines (55 loc) · 2.16 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
// CLI/Nginx/Cron: We need to set the "current working directory" to this folder
chdir(__DIR__);
// vendors not installed
if (!is_dir(__DIR__ . '/vendor')) {
echo 'Your install is missing some dependencies. If you have composer
installed you should run: <code>composer install</code>. If you
don\'t have composer installed you really should, see
http://getcomposer.org for more information';
return;
}
require_once __DIR__ . '/autoload.php';
use ForkCMS\App\AppKernel;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;
// get environment and debug mode from environment variables
$env = $_SERVER['FORK_ENV'] ?: 'prod';
$debug = $_SERVER['FORK_DEBUG'] === '1';
// Fork has not yet been installed
$parametersFile = __DIR__ . '/app/config/parameters.yml';
$request = Request::createFromGlobals();
if (!file_exists($parametersFile)) {
$env = 'install';
if (strpos($request->getRequestUri(), '/install') !== 0) {
// check .htaccess
if (!$request->query->has('skiphtaccess') && !file_exists('.htaccess')) {
echo 'Your install is missing the .htaccess file. Make sure you show
hidden files while uploading Fork CMS. Read the article about
<a href="http://www.fork-cms.com/community/documentation/detail/installation/webservers">webservers</a>
for further information. <a href="?skiphtaccess">Skip .htaccess
check</a>';
return;
}
header('Location: /install');
return;
}
}
if (extension_loaded('newrelic')) {
newrelic_name_transaction(strtok($request->getRequestUri(), '?'));
}
if ($debug) {
\Symfony\Component\ErrorHandler\Debug::enable();
}
$kernel = new AppKernel($env, $debug);
$response = $kernel->handle($request);
if ($response->getCharset() === null && $kernel->getContainer() instanceof ContainerInterface) {
$response->setCharset(
$kernel->getContainer()->getParameter('kernel.charset')
);
}
$response->send();
if (!$kernel->isInstallingModule()) {
$kernel->terminate($request, $response);
}