Skip to content

Commit 7673a4f

Browse files
author
Greg Bowler
committed
Merge branch 'master' of github.com:/PhpGt/WebEngine into 299-error-handling
# Conflicts: # composer.lock # src/Middleware/RequestHandler.php
2 parents f68a1f6 + 8bb7416 commit 7673a4f

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

setup.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Run this script from the root directory of your WebEngine project.
4+
* e.g. php vendor/phpgt/webengine/setup.php
5+
*
6+
* The purpose of this script is to make sure that the project is set up
7+
* correctly, if it has been installed manually, rather than via the composer
8+
* create-project command.
9+
*/
10+
$error = null;
11+
if(!is_dir("vendor")) {
12+
if(!is_file("composer.json")) {
13+
$error = "The current directory is not a WebEngine project.";
14+
}
15+
$error = "No vendor directory found - do you need to run `composer install`?";
16+
}
17+
if(is_file("build.default.json")) {
18+
$error = "Please run this script from your project's root directory.";
19+
}
20+
if($error) {
21+
echo "$error See https://www.php.gt/webengine/setup for more information.", PHP_EOL;
22+
exit(1);
23+
}
24+
$indexPhpContents = <<<PHP
25+
<?php
26+
require(__DIR__ . "/../vendor/phpgt/webengine/go.php");
27+
PHP;
28+
29+
if(!is_dir("www")) {
30+
mkdir("www");
31+
}
32+
file_put_contents("www/index.php", $indexPhpContents);

src/Middleware/RequestHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ protected function handleCsrf(ServerRequestInterface $request):void {
270270
);
271271
$tokens = $protector->protect($sharing);
272272
$this->response = $this->response->withHeader($this->config->getString("security.csrf_header"), $tokens);
273-
}
273+
}
274+
274275
}
275276

276277
protected function handleProtectedGlobals():void {

0 commit comments

Comments
 (0)