Skip to content

Commit 2128178

Browse files
committed
Add check.php file for access from web
I propose to get Symfony's `config.php` configurator file and rename it to `check.php` with some minor changes in order to get ability to check required and optional environment configuration parameters directly from web browser for success run this demo project. It's like `app/check.php` file for console, but allow users to check environment directly from web browser. I think it will be useful for beginners. What do you think, guys?
1 parent deaceb9 commit 2128178

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

web/check.php

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<?php
2+
3+
if (!isset($_SERVER['HTTP_HOST'])) {
4+
exit('This script cannot be run from the CLI. Run it from a browser.');
5+
}
6+
7+
if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
8+
'127.0.0.1',
9+
'::1',
10+
))) {
11+
header('HTTP/1.0 403 Forbidden');
12+
exit('This script is only accessible from localhost.');
13+
}
14+
15+
require_once dirname(__FILE__).'/../app/SymfonyRequirements.php';
16+
17+
$symfonyRequirements = new SymfonyRequirements();
18+
19+
$majorProblems = $symfonyRequirements->getFailedRequirements();
20+
$minorProblems = $symfonyRequirements->getFailedRecommendations();
21+
22+
?>
23+
<!DOCTYPE html>
24+
<html>
25+
<head>
26+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
27+
<meta name="robots" content="noindex,nofollow" />
28+
<title>Symfony Configuration</title>
29+
<link rel="stylesheet" href="bundles/framework/css/structure.css" media="all" />
30+
<link rel="stylesheet" href="bundles/framework/css/body.css" media="all" />
31+
<link rel="stylesheet" href="bundles/sensiodistribution/webconfigurator/css/install.css" media="all" />
32+
</head>
33+
<body>
34+
<div id="content">
35+
<div class="header clear-fix">
36+
<div class="header-logo">
37+
<img src="bundles/framework/images/logo_symfony.png" alt="Symfony" />
38+
</div>
39+
40+
<div class="search">
41+
<form method="get" action="http://symfony.com/search">
42+
<div class="form-row">
43+
44+
<label for="search-id">
45+
<img src="bundles/framework/images/grey_magnifier.png" alt="Search on Symfony website" />
46+
</label>
47+
48+
<input name="q" id="search-id" type="search" placeholder="Search on Symfony website" />
49+
50+
<button type="submit" class="sf-button">
51+
<span class="border-l">
52+
<span class="border-r">
53+
<span class="btn-bg">OK</span>
54+
</span>
55+
</span>
56+
</button>
57+
</div>
58+
</form>
59+
</div>
60+
</div>
61+
62+
<div class="sf-reset">
63+
<div class="block">
64+
<div class="symfony-block-content">
65+
<h1 class="title">Welcome!</h1>
66+
<p>Welcome to the <strong>Symfony Demo Application</strong>.</p>
67+
<p>
68+
This script will guide you through the required and optional environment configuration parameters for this project.
69+
</p>
70+
71+
<?php if (count($majorProblems)): ?>
72+
<h2 class="ko">Major problems</h2>
73+
<p>Major problems have been detected and <strong>must</strong> be fixed before continuing:</p>
74+
<ol>
75+
<?php foreach ($majorProblems as $problem): ?>
76+
<li><?php echo $problem->getHelpHtml() ?></li>
77+
<?php endforeach; ?>
78+
</ol>
79+
<?php endif; ?>
80+
81+
<?php if (count($minorProblems)): ?>
82+
<h2>Recommendations</h2>
83+
<p>
84+
<?php if (count($majorProblems)): ?>Additionally, to<?php else: ?>To<?php endif; ?> enhance your Symfony experience,
85+
it’s recommended that you fix the following:
86+
</p>
87+
<ol>
88+
<?php foreach ($minorProblems as $problem): ?>
89+
<li><?php echo $problem->getHelpHtml() ?></li>
90+
<?php endforeach; ?>
91+
</ol>
92+
<?php endif; ?>
93+
94+
<?php if ($symfonyRequirements->hasPhpIniConfigIssue()): ?>
95+
<p id="phpini">*
96+
<?php if ($symfonyRequirements->getPhpIniConfigPath()): ?>
97+
Changes to the <strong>php.ini</strong> file must be done in "<strong><?php echo $symfonyRequirements->getPhpIniConfigPath() ?></strong>".
98+
<?php else: ?>
99+
To change settings, create a "<strong>php.ini</strong>".
100+
<?php endif; ?>
101+
</p>
102+
<?php endif; ?>
103+
104+
<?php if (!count($majorProblems) && !count($minorProblems)): ?>
105+
<p class="ok">Your configuration looks good to run Symfony Demo Application.</p>
106+
<?php endif; ?>
107+
108+
<ul class="symfony-install-continue">
109+
<?php if (!count($majorProblems)): ?>
110+
<li><a href="app_dev.php/">Go to the Welcome page</a></li>
111+
<?php endif; ?>
112+
<?php if (count($majorProblems) || count($minorProblems)): ?>
113+
<li><a href="config.php">Re-check configuration</a></li>
114+
<?php endif; ?>
115+
</ul>
116+
</div>
117+
</div>
118+
</div>
119+
<div class="version">Symfony Demo Application</div>
120+
</div>
121+
</body>
122+
</html>

0 commit comments

Comments
 (0)