Skip to content

Commit dac8686

Browse files
author
Greg Bowler
committed
Merge branch 'master' of github.com:/PhpGt/WebEngine
# Conflicts: # src/Middleware/Lifecycle.php
2 parents 211f4c2 + b79566a commit dac8686

File tree

9 files changed

+576
-259
lines changed

9 files changed

+576
-259
lines changed

build.default.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,17 @@
77
},
88
"execute": {
99
"command": "webpack",
10-
"arguments": ["--entry","./script/script.es6", "--output-path", "./www", "--output-filename", "script.js", "--devtool", "source-map", "--mode", "production"]
10+
"arguments": ["--entry","./script/script.es6", "--output-path", "./www", "--output-filename", "script.js", "--devtool", "source-map", "--mode", "development"]
11+
}
12+
},
13+
14+
"script/*sw.js": {
15+
"require": {
16+
"vendor/bin/sync": "*"
17+
},
18+
"execute": {
19+
"command": "vendor/bin/sync",
20+
"arguments": ["--pattern", "*sw.js", "script", "www/"]
1121
}
1222
},
1323

composer.lock

Lines changed: 50 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99
chdir(dirname($_SERVER["DOCUMENT_ROOT"]));
1010
ini_set("display_errors", "on");
11+
ini_set("html_errors", "false");
1112
/**
1213
* Before any code is executed, return false here if a static file is requested.
1314
* When running the PHP inbuilt server, this will output the static file.
@@ -26,7 +27,7 @@
2627
* files exist.
2728
* @link https://getcomposer.org/doc/00-intro.md
2829
*/
29-
foreach([__DIR__, dirname($_SERVER["DOCUMENT_ROOT"])] as $dir) {
30+
foreach([dirname($_SERVER["DOCUMENT_ROOT"]), __DIR__] as $dir) {
3031
$autoloadPath = "$dir/vendor/autoload.php";
3132
if(file_exists($autoloadPath)) {
3233
/** @noinspection PhpIncludeInspection */

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/Logic/LogicExecutor.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace Gt\WebEngine\Logic;
33

4+
use Generator;
45
use Gt\Routing\Assembly;
56
use Gt\Routing\LogicStream\LogicStreamNamespace;
67
use Gt\Routing\LogicStream\LogicStreamWrapper;
@@ -17,7 +18,8 @@ public function __construct(
1718
}
1819
}
1920

20-
public function invoke(string $name):void {
21+
/** @return Generator<string> filename::function() */
22+
public function invoke(string $name):Generator {
2123
foreach($this->assembly as $file) {
2224
$nsProject = (string)(new LogicProjectNamespace(
2325
$file,
@@ -36,6 +38,7 @@ public function invoke(string $name):void {
3638
$instance,
3739
$name
3840
);
41+
yield "$file::$name()";
3942
}
4043
}
4144
else {
@@ -52,6 +55,7 @@ public function invoke(string $name):void {
5255
null,
5356
$fnReference
5457
);
58+
yield "$file::$name()";
5559
}
5660
}
5761
}
@@ -60,6 +64,6 @@ public function invoke(string $name):void {
6064

6165
private function loadLogicFile(string $file):void {
6266
$streamPath = LogicStreamWrapper::STREAM_NAME . "://$file";
63-
require($streamPath);
67+
require_once($streamPath);
6468
}
6569
}

0 commit comments

Comments
 (0)