diff --git a/composer.json b/composer.json index f660dd6..d9fa7e2 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,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" @@ -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/composer.lock b/composer.lock index 81b2894..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": "7af3db8a87807f5835172f04485d4013", + "content-hash": "9966c2a171aa2843c7455209b3f886e3", "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,7 +371,7 @@ "type": "github" } ], - "time": "2023-09-18T10:06:17+00:00" + "time": "2024-05-08T17:45:44+00:00" }, { "name": "phpgt/config", @@ -476,24 +478,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 +509,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,26 +590,28 @@ }, { "name": "phpgt/server", - "version": "v1.1.4", + "version": "dev-master", "source": { "type": "git", - "url": "https://github.com/PhpGt/Server.git", - "reference": "6eec4cfcb0802fa409deb10713651ee842a228de" + "url": "https://github.com/phpgt/Server.git", + "reference": "04f877d43d245711591e9f83c814d06d82151de1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PhpGt/Server/zipball/6eec4cfcb0802fa409deb10713651ee842a228de", - "reference": "6eec4cfcb0802fa409deb10713651ee842a228de", + "url": "https://api.github.com/repos/phpgt/Server/zipball/04f877d43d245711591e9f83c814d06d82151de1", + "reference": "04f877d43d245711591e9f83c814d06d82151de1", "shasum": "" }, "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" }, + "default-branch": true, "bin": [ "bin/serve" ], @@ -617,8 +624,8 @@ "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" + "issues": "https://github.com/phpgt/Server/issues", + "source": "https://github.com/phpgt/Server/tree/master" }, "funding": [ { @@ -626,20 +633,20 @@ "type": "github" } ], - "time": "2022-07-24T22:38:50+00:00" + "time": "2026-03-20T15:11:16+00:00" }, { "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 +682,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 +691,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 +734,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 +743,7 @@ "type": "github" } ], - "time": "2023-04-28T14:42:27+00:00" + "time": "2026-03-10T22:28:01+00:00" }, { "name": "webmozart/assert", @@ -2062,9 +2069,18 @@ "time": "2025-09-11T10:15:23+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "phpgt/server", + "version": "9999999-dev", + "alias": "v1.2.3", + "alias_normalized": "1.2.3.0" + } + ], "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..1cac9e4 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,20 +65,38 @@ 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); 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."); }