diff --git a/.idea/Web.iml b/.idea/Web.iml
index 1e67c81..a0e9496 100644
--- a/.idea/Web.iml
+++ b/.idea/Web.iml
@@ -12,10 +12,8 @@
-
-
@@ -26,9 +24,8 @@
-
-
+
diff --git a/.idea/php.xml b/.idea/php.xml
index eebbe0d..a08f1b5 100644
--- a/.idea/php.xml
+++ b/.idea/php.xml
@@ -15,7 +15,6 @@
-
@@ -23,12 +22,9 @@
-
-
-
@@ -36,6 +32,7 @@
+
diff --git a/config/server.php b/config/server.php
index 73c0ca3..c32a94d 100644
--- a/config/server.php
+++ b/config/server.php
@@ -9,7 +9,7 @@
*/
return [
- 'listen' => 'http://0.0.0.0:88',
+ 'listen' => 'http://0.0.0.0:8000',
'transport' => 'tcp',
'context' => [],
'name' => 'Triangle',
diff --git a/master b/master
index 08070a6..947b6d1 100644
--- a/master
+++ b/master
@@ -24,7 +24,9 @@
* along with this program. If not, see .
*/
+use support\Container;
use Triangle\Console;
+use Triangle\Console\Util;
use Triangle\Engine\Config;
require_once __DIR__ . '/vendor/autoload.php';
@@ -32,8 +34,8 @@ require_once __DIR__ . '/vendor/autoload.php';
if (!in_array($argv[1] ?? '', ['start', 'restart', 'stop', 'status', 'reload', 'connections'])) {
require_once __DIR__ . '/support/bootstrap.php';
} else {
- if (class_exists('support\App')) {
- support\App::loadAllConfig(['route']);
+ if (class_exists('Support\App')) {
+ Support\App::loadAllConfig(['route']);
} else {
Config::load(config_path(), ['route', 'container']);
}
@@ -41,20 +43,38 @@ if (!in_array($argv[1] ?? '', ['start', 'restart', 'stop', 'status', 'reload', '
$cli = new Console();
$cli->setName('Triangle CLI');
-if (is_dir($command_path = app_path('command'))) {
+$cli->installInternalCommands();
+if (is_dir($command_path = Util::guessPath(app_path(), '/command', true))) {
$cli->installCommands($command_path);
}
foreach (config('plugin', []) as $firm => $projects) {
- if (config("plugin.$firm.app", false)) continue;
+ if (isset($projects['app'])) {
+ if ($command_str = Util::guessPath(base_path() . "/plugin/$firm", 'command')) {
+ $command_path = base_path() . "/plugin/$firm/$command_str";
+ $cli->installCommands($command_path, "plugin\\$firm\\$command_str");
+ }
+ }
foreach ($projects as $name => $project) {
- foreach ($project['command'] ?? [] as $command) {
- $cli->add(new $command);
+ if (!is_array($project)) {
+ continue;
+ }
+ foreach ($project['command'] ?? [] as $class_name) {
+ $reflection = new ReflectionClass($class_name);
+ if ($reflection->isAbstract()) {
+ continue;
+ }
+ $properties = $reflection->getStaticProperties();
+ $name = $properties['defaultName'];
+ if (!$name) {
+ throw new RuntimeException("Command {$class_name} has no defaultName");
+ }
+ $description = $properties['defaultDescription'] ?? '';
+ $command = Container::get($class_name);
+ $command->setName($name)->setDescription($description);
+ $cli->add($command);
}
}
}
-try {
- $cli->run();
-} catch (Exception $e) {
-}
+$cli->run();
diff --git a/support/bootstrap.php b/support/bootstrap.php
index 31942b3..85370e4 100644
--- a/support/bootstrap.php
+++ b/support/bootstrap.php
@@ -1,18 +1,18 @@
- * @copyright Copyright (c) 2018-2024 Localzet Group
- * @license https://www.gnu.org/licenses/agpl AGPL-3.0 license
+ * @copyright Copyright (c) 2018-2024 Zorin Projects S.P.
+ * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -21,6 +21,8 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
+ *
+ * For any questions, please contact
*/
use Dotenv\Dotenv;
diff --git a/support/helpers.php b/support/helpers.php
index d44f80f..c29c574 100644
--- a/support/helpers.php
+++ b/support/helpers.php
@@ -28,6 +28,7 @@
use localzet\Server\Connection\TcpConnection;
use localzet\Server\Protocols\Http\Session;
use support\Container;
+use support\Env;
use support\Response;
use support\Translation;
use Triangle\Engine\App;
@@ -79,14 +80,7 @@ function response(mixed $body = '', int $status = 200, array $headers = [], bool
*/
function responseBlob(string $blob, string $type = 'image/png'): Response
{
- return new Response(
- 200,
- [
- 'Content-Type' => $type,
- 'Content-Length' => strlen($blob)
- ],
- $blob
- );
+ return new Response(200, ['Content-Type' => $type], $blob);
}
/**
@@ -451,14 +445,24 @@ function locale(string $locale = null): string
/**
* @param string|null $key
- * @param $default
- * @return array|mixed|null
+ * * @param mixed|null $default
+ * @return mixed
*/
-function config(string $key = null, $default = null): mixed
+function config(string $key = null, mixed $default = null): mixed
{
return Config::get($key, $default);
}
+/**
+ * @param string|null $key
+ * @param mixed|null $default
+ * @return mixed
+ */
+function env(string $key = null, mixed $default = null): mixed
+{
+ return Env::get($key, $default);
+}
+
/**
* @return TcpConnection|null
*/