diff --git a/.gitignore b/.gitignore index 24f8843..d1502b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,2 @@ -.idea/ -.vscode/ -/vendor/ +vendor/ composer.lock diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..e0147b4 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Launch DevNet Application", + "type": "php", + "request": "launch", + "cwd": "${workspaceRoot}/bin/", + "runtimeArgs": [ + "-dxdebug.start_with_request=yes", + "apphost" + ], + "env": { + "XDEBUG_MODE": "debug,develop" + } + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 4c1cc30..bd5ea06 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # DevNet Console Template -This package is a Console application template of DevNet Framewark. +This package is a Console application template of DevNet Framework. ## Requirements -- PHP 7.4 or higher version from [php.net](https://www.php.net/) -- Composer the dependency manager from [getcomposer.org](https://getcomposer.org/) +- [PHP](https://www.php.net/) version 8.1 or higher +- [Composer](https://getcomposer.org/) version 2.0 or higher ## Installation To create a DevNet Console Application project using composer, run the following command in your terminal: diff --git a/bin/apphost b/bin/apphost index 3ce81d7..39da7e6 100644 --- a/bin/apphost +++ b/bin/apphost @@ -2,35 +2,33 @@ use DevNet\System\Runtime\Launcher; -$projectFile = simplexml_load_file(__DIR__ . "/../project.phproj"); -$namespace = $projectFile->properties->namespace; -$entrypoint = $projectFile->properties->entrypoint; -$packages = $projectFile->dependencies->package ?? []; +$root = dirname(__FILE__, 2); +// Loads local devnet core host if exist +if (is_file($root . '/vendor/devnet/core/host/corehost.php')) { + require $root . '/vendor/devnet/core/host/corehost.php'; +} + +// Gets the path environment variable if (PHP_OS_FAMILY == 'Windows') { - $path = getenv('path'); - $paths = explode(';', $path); + $paths = explode(';', getenv('path')); } else { - $path = getenv('PATH'); - $paths = explode(':', $path); + $paths = explode(':', getenv('PATH')); } +// Search for the global devnet core host foreach ($paths as $path) { - if (file_exists($path . '/../autoload.php')) { - require $path . '/../autoload.php'; + if (is_file($path . '/../devnet/core/host/corehost.php')) { + require $path . '/../devnet/core/host/corehost.php'; break; } } -foreach ($packages as $package) { - $include = (string)$package->attributes()->include; - if (file_exists(__DIR__ . '/../' . $include)) { - require __DIR__ . '/../' . $include; - } -} -$launcher = Launcher::getLauncher(); -$launcher->workspace(dirname(__DIR__)); -$launcher->namespace((string)$namespace); -$launcher->entryPoint((string)$entrypoint); -$launcher->launch(); +// Gets the console arguments without command name +$args = $GLOBALS['argv'] ?? []; +array_shift($args); + +// Initialize and launch the application +$launcher = Launcher::initialize($root . '/devnet.proj'); +$launcher->launch($args); diff --git a/composer.json b/composer.json index 7cdaa95..4ce79d3 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "devnet/console-template", - "description": "DevNet Console Application", - "type": "devnet-project", + "description": "Console Application", + "type": "project", "license": "MIT", "minimum-stability": "dev", "prefer-stable": true diff --git a/devnet.proj b/devnet.proj new file mode 100644 index 0000000..8ba44fc --- /dev/null +++ b/devnet.proj @@ -0,0 +1,9 @@ + + + + Application\Program + + + + + \ No newline at end of file diff --git a/project.phproj b/project.phproj deleted file mode 100644 index caa60c6..0000000 --- a/project.phproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - Application - Program - - - - - diff --git a/Program.php b/src/Program.php similarity index 76% rename from Program.php rename to src/Program.php index 83aea00..8eddacf 100644 --- a/Program.php +++ b/src/Program.php @@ -8,6 +8,6 @@ class Program { public static function main(array $args = []) { - Console::writeline("Hello World!"); + Console::writeLine("Hello World!"); } }