From 050035a158ac19a502516d05214b7e430db50058 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Sat, 21 Mar 2026 12:40:35 +0000 Subject: [PATCH 1/4] feature: explain how to stop the server closes phpgt/server#9 --- composer.json | 9 +- composer.lock | 172 +++++++++++++++++++------------------ src/Command/RunCommand.php | 20 ++++- 3 files changed, 115 insertions(+), 86 deletions(-) diff --git a/composer.json b/composer.json index f660dd6..2e89035 100644 --- a/composer.json +++ b/composer.json @@ -1,4 +1,11 @@ { + "repositories": [{ + "type": "path", + "url": "/home/g105b/Code/PhpGt/Server", + "options": { + "symlink": true + } + }], "name": "phpgt/gtcommand", "description": "Provides the `gt` command for automating WebEngine development.", "bin": [ @@ -8,7 +15,7 @@ "require": { "php": ">=8.2", "phpgt/cli": "^1.3", - "phpgt/server": "^1.1", + "phpgt/server": "dev-master as v1.2.3", "phpgt/cron": "^1.0", "phpgt/database": "^1.6", "phpgt/build": "^1.0" diff --git a/composer.lock b/composer.lock index 81b2894..6cba4fd 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7af3db8a87807f5835172f04485d4013", + "content-hash": "d792943a7ee79b4fa7473d793309f074", "packages": [ { "name": "composer/semver", @@ -314,27 +314,29 @@ }, { "name": "phpgt/cli", - "version": "v1.3.4", + "version": "v1.3.5", "source": { "type": "git", "url": "https://github.com/PhpGt/Cli.git", - "reference": "71deb9cdc5a3ea8bfb665faa29739badbf61e9da" + "reference": "42aeef24ab9789907358002fdcc37cb3a2e26b4b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PhpGt/Cli/zipball/71deb9cdc5a3ea8bfb665faa29739badbf61e9da", - "reference": "71deb9cdc5a3ea8bfb665faa29739badbf61e9da", + "url": "https://api.github.com/repos/PhpGt/Cli/zipball/42aeef24ab9789907358002fdcc37cb3a2e26b4b", + "reference": "42aeef24ab9789907358002fdcc37cb3a2e26b4b", "shasum": "" }, "require": { "ext-json": "*", "ext-readline": "*", - "php": ">=8.0", - "phpgt/daemon": "^v1.1" + "php": ">=8.2", + "phpgt/daemon": "^1.1.3" }, "require-dev": { - "phpstan/phpstan": "^v1.8", - "phpunit/phpunit": "^v9.5" + "phpmd/phpmd": "^2.13", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^10.5", + "squizlabs/php_codesniffer": "^3.7" }, "type": "library", "autoload": { @@ -361,7 +363,7 @@ ], "support": { "issues": "https://github.com/PhpGt/Cli/issues", - "source": "https://github.com/PhpGt/Cli/tree/v1.3.4" + "source": "https://github.com/PhpGt/Cli/tree/v1.3.5" }, "funding": [ { @@ -369,30 +371,32 @@ "type": "github" } ], - "time": "2023-09-18T10:06:17+00:00" + "time": "2024-05-08T17:45:44+00:00" }, { "name": "phpgt/config", - "version": "v1.1.1", + "version": "v1.2.0", "source": { "type": "git", "url": "https://github.com/phpgt/Config.git", - "reference": "e693bc69af7b844b9b393e8a88755de962b606fe" + "reference": "21fa25f3dca864ecc9c54800a4394eb5601f2c4d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpgt/Config/zipball/e693bc69af7b844b9b393e8a88755de962b606fe", - "reference": "e693bc69af7b844b9b393e8a88755de962b606fe", + "url": "https://api.github.com/repos/phpgt/Config/zipball/21fa25f3dca864ecc9c54800a4394eb5601f2c4d", + "reference": "21fa25f3dca864ecc9c54800a4394eb5601f2c4d", "shasum": "" }, "require": { "magicalex/write-ini-file": "v1.2.4", - "php": ">=8.2", + "php": ">=8.3", "phpgt/typesafegetter": "^v1.2" }, "require-dev": { + "phpmd/phpmd": "^2.15", "phpstan/phpstan": "^2.1", - "phpunit/phpunit": "^12.4" + "phpunit/phpunit": "^12.4", + "squizlabs/php_codesniffer": "^4.0" }, "bin": [ "bin/config-generate" @@ -416,7 +420,7 @@ "description": "Manage configuration with ini files and environment variables.", "support": { "issues": "https://github.com/phpgt/Config/issues", - "source": "https://github.com/phpgt/Config/tree/v1.1.1" + "source": "https://github.com/phpgt/Config/tree/v1.2.0" }, "funding": [ { @@ -424,7 +428,7 @@ "type": "github" } ], - "time": "2025-10-19T12:31:15+00:00" + "time": "2026-03-16T11:04:06+00:00" }, { "name": "phpgt/cron", @@ -476,24 +480,27 @@ }, { "name": "phpgt/daemon", - "version": "v1.1.2", + "version": "v1.1.5", "source": { "type": "git", - "url": "https://github.com/PhpGt/Daemon.git", - "reference": "6490df99a22818149f30e3af408002ea7f73e035" + "url": "https://github.com/phpgt/Daemon.git", + "reference": "413e16b54de6e1fd5c2b646b485f88a86dfedd9a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PhpGt/Daemon/zipball/6490df99a22818149f30e3af408002ea7f73e035", - "reference": "6490df99a22818149f30e3af408002ea7f73e035", + "url": "https://api.github.com/repos/phpgt/Daemon/zipball/413e16b54de6e1fd5c2b646b485f88a86dfedd9a", + "reference": "413e16b54de6e1fd5c2b646b485f88a86dfedd9a", "shasum": "" }, "require": { - "php": ">=7.4" + "ext-pcntl": "*", + "php": ">=8.1" }, "require-dev": { - "phpstan/phpstan": ">=0.12.42", - "phpunit/phpunit": "9.*" + "phpmd/phpmd": "^2.13", + "phpstan/phpstan": "^v1.10", + "phpunit/phpunit": "^10.5", + "squizlabs/php_codesniffer": "^3.7" }, "type": "library", "autoload": { @@ -504,16 +511,16 @@ "notification-url": "https://packagist.org/downloads/", "description": "Background script execution with cross-platform compatible streaming.", "support": { - "issues": "https://github.com/PhpGt/Daemon/issues", - "source": "https://github.com/PhpGt/Daemon/tree/v1.1.2" + "issues": "https://github.com/phpgt/Daemon/issues", + "source": "https://github.com/phpgt/Daemon/tree/v1.1.5" }, "funding": [ { - "url": "https://github.com/phpgt", + "url": "https://github.com/sponsors/PhpGt", "type": "github" } ], - "time": "2021-02-02T17:33:16+00:00" + "time": "2026-03-11T14:11:10+00:00" }, { "name": "phpgt/database", @@ -585,25 +592,20 @@ }, { "name": "phpgt/server", - "version": "v1.1.4", - "source": { - "type": "git", - "url": "https://github.com/PhpGt/Server.git", - "reference": "6eec4cfcb0802fa409deb10713651ee842a228de" - }, + "version": "dev-master", "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PhpGt/Server/zipball/6eec4cfcb0802fa409deb10713651ee842a228de", - "reference": "6eec4cfcb0802fa409deb10713651ee842a228de", - "shasum": "" + "type": "path", + "url": "/home/g105b/Code/PhpGt/Server", + "reference": "d35a0634d860112706f7b644a437103fc8fe7059" }, "require": { - "php": ">=7.4", - "phpgt/cli": "*" + "php": ">=8.0", + "phpgt/cli": "^1.3.5" }, "require-dev": { - "phpstan/phpstan": "v1.8.0", - "phpunit/phpunit": "v9.5.21" + "phpmd/phpmd": "^2.13", + "phpstan/phpstan": "^2.1", + "squizlabs/php_codesniffer": "^3.7" }, "bin": [ "bin/serve" @@ -614,32 +616,30 @@ "Gt\\Server\\": "./src/" } }, - "notification-url": "https://packagist.org/downloads/", "description": "Development HTTP server.", - "support": { - "issues": "https://github.com/PhpGt/Server/issues", - "source": "https://github.com/PhpGt/Server/tree/v1.1.4" - }, "funding": [ { - "url": "https://github.com/sponsors/PhpGt", - "type": "github" + "type": "github", + "url": "https://github.com/sponsors/PhpGt" } ], - "time": "2022-07-24T22:38:50+00:00" + "transport-options": { + "symlink": true, + "relative": false + } }, { "name": "phpgt/sync", - "version": "v1.3.0", + "version": "v1.3.1", "source": { "type": "git", - "url": "https://github.com/PhpGt/Sync.git", - "reference": "5d1ee6aaa0b97919629c83a90745a1407ddfd66c" + "url": "https://github.com/phpgt/Sync.git", + "reference": "147c2ae1f3670bc606093892a01175584c082e64" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PhpGt/Sync/zipball/5d1ee6aaa0b97919629c83a90745a1407ddfd66c", - "reference": "5d1ee6aaa0b97919629c83a90745a1407ddfd66c", + "url": "https://api.github.com/repos/phpgt/Sync/zipball/147c2ae1f3670bc606093892a01175584c082e64", + "reference": "147c2ae1f3670bc606093892a01175584c082e64", "shasum": "" }, "require": { @@ -675,8 +675,8 @@ "synchronize" ], "support": { - "issues": "https://github.com/PhpGt/Sync/issues", - "source": "https://github.com/PhpGt/Sync/tree/v1.3.0" + "issues": "https://github.com/phpgt/Sync/issues", + "source": "https://github.com/phpgt/Sync/tree/v1.3.1" }, "funding": [ { @@ -684,20 +684,20 @@ "type": "github" } ], - "time": "2023-07-07T16:49:08+00:00" + "time": "2026-03-15T17:45:10+00:00" }, { "name": "phpgt/typesafegetter", - "version": "v1.3.2", + "version": "v1.3.3", "source": { "type": "git", - "url": "https://github.com/PhpGt/TypeSafeGetter.git", - "reference": "f760c05a37b1cc188dcbf800c5fdfab8a926b4b0" + "url": "https://github.com/phpgt/TypeSafeGetter.git", + "reference": "a0d339103828791989cbb81f760d252f3c2f8b8c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PhpGt/TypeSafeGetter/zipball/f760c05a37b1cc188dcbf800c5fdfab8a926b4b0", - "reference": "f760c05a37b1cc188dcbf800c5fdfab8a926b4b0", + "url": "https://api.github.com/repos/phpgt/TypeSafeGetter/zipball/a0d339103828791989cbb81f760d252f3c2f8b8c", + "reference": "a0d339103828791989cbb81f760d252f3c2f8b8c", "shasum": "" }, "require": { @@ -727,8 +727,8 @@ ], "description": "An interface for objects that expose type-safe getter methods.", "support": { - "issues": "https://github.com/PhpGt/TypeSafeGetter/issues", - "source": "https://github.com/PhpGt/TypeSafeGetter/tree/v1.3.2" + "issues": "https://github.com/phpgt/TypeSafeGetter/issues", + "source": "https://github.com/phpgt/TypeSafeGetter/tree/v1.3.3" }, "funding": [ { @@ -736,7 +736,7 @@ "type": "github" } ], - "time": "2023-04-28T14:42:27+00:00" + "time": "2026-03-10T22:28:01+00:00" }, { "name": "webmozart/assert", @@ -1982,26 +1982,25 @@ }, { "name": "symfony/var-exporter", - "version": "v7.4.0", + "version": "v8.0.0", "source": { "type": "git", "url": "https://github.com/symfony/var-exporter.git", - "reference": "03a60f169c79a28513a78c967316fbc8bf17816f" + "reference": "7345f46c251f2eb27c7b3ebdb5bb076b3ffcae04" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-exporter/zipball/03a60f169c79a28513a78c967316fbc8bf17816f", - "reference": "03a60f169c79a28513a78c967316fbc8bf17816f", + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/7345f46c251f2eb27c7b3ebdb5bb076b3ffcae04", + "reference": "7345f46c251f2eb27c7b3ebdb5bb076b3ffcae04", "shasum": "" }, "require": { - "php": ">=8.2", - "symfony/deprecation-contracts": "^2.5|^3" + "php": ">=8.4" }, "require-dev": { - "symfony/property-access": "^6.4|^7.0|^8.0", - "symfony/serializer": "^6.4|^7.0|^8.0", - "symfony/var-dumper": "^6.4|^7.0|^8.0" + "symfony/property-access": "^7.4|^8.0", + "symfony/serializer": "^7.4|^8.0", + "symfony/var-dumper": "^7.4|^8.0" }, "type": "library", "autoload": { @@ -2039,7 +2038,7 @@ "serialize" ], "support": { - "source": "https://github.com/symfony/var-exporter/tree/v7.4.0" + "source": "https://github.com/symfony/var-exporter/tree/v8.0.0" }, "funding": [ { @@ -2059,12 +2058,21 @@ "type": "tidelift" } ], - "time": "2025-09-11T10:15:23+00:00" + "time": "2025-11-05T18:53:00+00:00" + } + ], + "aliases": [ + { + "package": "phpgt/server", + "version": "9999999-dev", + "alias": "v1.2.3", + "alias_normalized": "1.2.3.0" } ], - "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": { + "phpgt/server": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/src/Command/RunCommand.php b/src/Command/RunCommand.php index ca186ac..4b40978 100644 --- a/src/Command/RunCommand.php +++ b/src/Command/RunCommand.php @@ -7,6 +7,7 @@ use Gt\Cli\Stream; use Gt\Daemon\Pool; use Gt\Daemon\Process; +use Gt\GtCommand\UI\Egg\RandomStartingMessage; class RunCommand extends Command { /** @@ -40,7 +41,7 @@ public function run(?ArgumentValueList $arguments = null):void { $processList["build"] = new Process($argv[0], "build", "--watch"); } - if(!$arguments->contains("no-cron")) { + if(!$arguments->contains("no-cron") && is_file("crontab")) { $processList["cron"] = new Process($argv[0], "cron", "--watch"); } @@ -64,14 +65,27 @@ public function run(?ArgumentValueList $arguments = null):void { $localUrl .= ":$portValue"; } - usleep(100_000); + $this->write("Starting WebEngine..."); + usleep(500_000); if($processList["serve"]->isRunning()) { - $this->writeLine("To view your application in your " + $this->writeLine(" ✅"); + usleep(500_000); + $this->writeLine(); + $this->writeLine("To view your application in your" . " browser, visit: $localUrl"); $this->writeLine("To stop running, press [CTRL]+[C]."); $this->writeLine(); + usleep(500_000); + } + else { + $this->writeLine(" ❌"); + $this->write($processList["serve"]->getOutput(Process::PIPE_ERROR), Stream::ERROR); + return; } + $this->write($processList["serve"]->getOutput()); + $this->write($processList["serve"]->getOutput(Process::PIPE_ERROR), Stream::ERROR); + do { $this->write($pool->read()); $this->write($pool->read(Process::PIPE_ERROR), Stream::ERROR); From 2e4fcfa3ba4ea140f57718622f43a7255b51dddb Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Sat, 21 Mar 2026 12:43:01 +0000 Subject: [PATCH 2/4] build: remove dev repo --- composer.json | 7 ------- 1 file changed, 7 deletions(-) diff --git a/composer.json b/composer.json index 2e89035..24f6eb5 100644 --- a/composer.json +++ b/composer.json @@ -1,11 +1,4 @@ { - "repositories": [{ - "type": "path", - "url": "/home/g105b/Code/PhpGt/Server", - "options": { - "symlink": true - } - }], "name": "phpgt/gtcommand", "description": "Provides the `gt` command for automating WebEngine development.", "bin": [ From 4f533531bb26ae5367f466d522572967984ef52a Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Sat, 21 Mar 2026 12:43:40 +0000 Subject: [PATCH 3/4] build: php 8.2 compatibility --- composer.lock | 68 ++++++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/composer.lock b/composer.lock index 6cba4fd..86e6167 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d792943a7ee79b4fa7473d793309f074", + "content-hash": "9966c2a171aa2843c7455209b3f886e3", "packages": [ { "name": "composer/semver", @@ -375,28 +375,26 @@ }, { "name": "phpgt/config", - "version": "v1.2.0", + "version": "v1.1.1", "source": { "type": "git", "url": "https://github.com/phpgt/Config.git", - "reference": "21fa25f3dca864ecc9c54800a4394eb5601f2c4d" + "reference": "e693bc69af7b844b9b393e8a88755de962b606fe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpgt/Config/zipball/21fa25f3dca864ecc9c54800a4394eb5601f2c4d", - "reference": "21fa25f3dca864ecc9c54800a4394eb5601f2c4d", + "url": "https://api.github.com/repos/phpgt/Config/zipball/e693bc69af7b844b9b393e8a88755de962b606fe", + "reference": "e693bc69af7b844b9b393e8a88755de962b606fe", "shasum": "" }, "require": { "magicalex/write-ini-file": "v1.2.4", - "php": ">=8.3", + "php": ">=8.2", "phpgt/typesafegetter": "^v1.2" }, "require-dev": { - "phpmd/phpmd": "^2.15", "phpstan/phpstan": "^2.1", - "phpunit/phpunit": "^12.4", - "squizlabs/php_codesniffer": "^4.0" + "phpunit/phpunit": "^12.4" }, "bin": [ "bin/config-generate" @@ -420,7 +418,7 @@ "description": "Manage configuration with ini files and environment variables.", "support": { "issues": "https://github.com/phpgt/Config/issues", - "source": "https://github.com/phpgt/Config/tree/v1.2.0" + "source": "https://github.com/phpgt/Config/tree/v1.1.1" }, "funding": [ { @@ -428,7 +426,7 @@ "type": "github" } ], - "time": "2026-03-16T11:04:06+00:00" + "time": "2025-10-19T12:31:15+00:00" }, { "name": "phpgt/cron", @@ -593,10 +591,16 @@ { "name": "phpgt/server", "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/phpgt/Server.git", + "reference": "04f877d43d245711591e9f83c814d06d82151de1" + }, "dist": { - "type": "path", - "url": "/home/g105b/Code/PhpGt/Server", - "reference": "d35a0634d860112706f7b644a437103fc8fe7059" + "type": "zip", + "url": "https://api.github.com/repos/phpgt/Server/zipball/04f877d43d245711591e9f83c814d06d82151de1", + "reference": "04f877d43d245711591e9f83c814d06d82151de1", + "shasum": "" }, "require": { "php": ">=8.0", @@ -607,6 +611,7 @@ "phpstan/phpstan": "^2.1", "squizlabs/php_codesniffer": "^3.7" }, + "default-branch": true, "bin": [ "bin/serve" ], @@ -616,17 +621,19 @@ "Gt\\Server\\": "./src/" } }, + "notification-url": "https://packagist.org/downloads/", "description": "Development HTTP server.", + "support": { + "issues": "https://github.com/phpgt/Server/issues", + "source": "https://github.com/phpgt/Server/tree/master" + }, "funding": [ { - "type": "github", - "url": "https://github.com/sponsors/PhpGt" + "url": "https://github.com/sponsors/PhpGt", + "type": "github" } ], - "transport-options": { - "symlink": true, - "relative": false - } + "time": "2026-03-20T15:11:16+00:00" }, { "name": "phpgt/sync", @@ -1982,25 +1989,26 @@ }, { "name": "symfony/var-exporter", - "version": "v8.0.0", + "version": "v7.4.0", "source": { "type": "git", "url": "https://github.com/symfony/var-exporter.git", - "reference": "7345f46c251f2eb27c7b3ebdb5bb076b3ffcae04" + "reference": "03a60f169c79a28513a78c967316fbc8bf17816f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-exporter/zipball/7345f46c251f2eb27c7b3ebdb5bb076b3ffcae04", - "reference": "7345f46c251f2eb27c7b3ebdb5bb076b3ffcae04", + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/03a60f169c79a28513a78c967316fbc8bf17816f", + "reference": "03a60f169c79a28513a78c967316fbc8bf17816f", "shasum": "" }, "require": { - "php": ">=8.4" + "php": ">=8.2", + "symfony/deprecation-contracts": "^2.5|^3" }, "require-dev": { - "symfony/property-access": "^7.4|^8.0", - "symfony/serializer": "^7.4|^8.0", - "symfony/var-dumper": "^7.4|^8.0" + "symfony/property-access": "^6.4|^7.0|^8.0", + "symfony/serializer": "^6.4|^7.0|^8.0", + "symfony/var-dumper": "^6.4|^7.0|^8.0" }, "type": "library", "autoload": { @@ -2038,7 +2046,7 @@ "serialize" ], "support": { - "source": "https://github.com/symfony/var-exporter/tree/v8.0.0" + "source": "https://github.com/symfony/var-exporter/tree/v7.4.0" }, "funding": [ { @@ -2058,7 +2066,7 @@ "type": "tidelift" } ], - "time": "2025-11-05T18:53:00+00:00" + "time": "2025-09-11T10:15:23+00:00" } ], "aliases": [ From 69adc539e37a34df1f869dc2d03dcddf5faf026f Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Fri, 27 Mar 2026 11:57:44 +0000 Subject: [PATCH 4/4] tweak: suppress phpstan bug --- composer.json | 11 +++++++++++ src/Command/RunCommand.php | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 24f6eb5..d9fa7e2 100644 --- a/composer.json +++ b/composer.json @@ -30,6 +30,17 @@ } }, + "scripts": { + "phpstan": "vendor/bin/phpstan analyse --level 6 src --memory-limit 256M", + "phpcs": "vendor/bin/phpcs src --standard=phpcs.xml", + "phpmd": "vendor/bin/phpmd src/ text phpmd.xml", + "test": [ + "@phpstan", + "@phpcs", + "@phpmd" + ] + }, + "funding": [ { "type": "github", diff --git a/src/Command/RunCommand.php b/src/Command/RunCommand.php index 4b40978..1cac9e4 100644 --- a/src/Command/RunCommand.php +++ b/src/Command/RunCommand.php @@ -90,8 +90,13 @@ public function run(?ArgumentValueList $arguments = null):void { $this->write($pool->read()); $this->write($pool->read(Process::PIPE_ERROR), Stream::ERROR); usleep(100_000); + /** @var bool $isRunning + * @noinspection PhpRedundantVariableDocTypeInspection + * This is necessary to suppress "Do-while loop condition is always true" error from phpstan. Bug with stan? + */ + $isRunning = $processList["serve"]->isRunning(); } - while($processList["serve"]->isRunning()); + while($isRunning); $this->writeLine("The server process has ended."); }