Skip to content

Commit 1123773

Browse files
author
Greg Bowler
committed
feature: add setup.php to configure manually installed applications
closes #578
1 parent 0962ecb commit 1123773

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
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);

0 commit comments

Comments
 (0)