Skip to content

Commit b19d748

Browse files
committed
update the template with the new structure
1 parent 078ca81 commit b19d748

File tree

8 files changed

+56
-40
lines changed

8 files changed

+56
-40
lines changed

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
.idea/
2-
.vscode/
3-
/vendor/
1+
vendor/
42
composer.lock

.vscode/launch.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Launch DevNet Application",
9+
"type": "php",
10+
"request": "launch",
11+
"cwd": "${workspaceRoot}/bin/",
12+
"runtimeArgs": [
13+
"-dxdebug.start_with_request=yes",
14+
"apphost"
15+
],
16+
"env": {
17+
"XDEBUG_MODE": "debug,develop"
18+
}
19+
}
20+
]
21+
}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# DevNet Console Template
2-
This package is a Console application template of DevNet Framewark.
2+
This package is a Console application template of DevNet Framework.
33

44
## Requirements
5-
- PHP 7.4 or higher version from [php.net](https://www.php.net/)
6-
- Composer the dependency manager from [getcomposer.org](https://getcomposer.org/)
5+
- [PHP](https://www.php.net/) version 8.1 or higher
6+
- [Composer](https://getcomposer.org/) version 2.0 or higher
77

88
## Installation
99
To create a DevNet Console Application project using composer, run the following command in your terminal:

bin/apphost

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,33 @@
22

33
use DevNet\System\Runtime\Launcher;
44

5-
$projectFile = simplexml_load_file(__DIR__ . "/../project.phproj");
6-
$namespace = $projectFile->properties->namespace;
7-
$entrypoint = $projectFile->properties->entrypoint;
8-
$packages = $projectFile->dependencies->package ?? [];
5+
$root = dirname(__FILE__, 2);
96

7+
// Loads local devnet core host if exist
8+
if (is_file($root . '/vendor/devnet/core/host/corehost.php')) {
9+
require $root . '/vendor/devnet/core/host/corehost.php';
10+
}
11+
12+
// Gets the path environment variable
1013
if (PHP_OS_FAMILY == 'Windows') {
11-
$path = getenv('path');
12-
$paths = explode(';', $path);
14+
$paths = explode(';', getenv('path'));
1315
} else {
14-
$path = getenv('PATH');
15-
$paths = explode(':', $path);
16+
$paths = explode(':', getenv('PATH'));
1617
}
1718

19+
// Search for the global devnet core host
1820
foreach ($paths as $path) {
19-
if (file_exists($path . '/../autoload.php')) {
20-
require $path . '/../autoload.php';
21+
if (is_file($path . '/../devnet/core/host/corehost.php')) {
22+
require $path . '/../devnet/core/host/corehost.php';
2123
break;
2224
}
2325
}
2426

25-
foreach ($packages as $package) {
26-
$include = (string)$package->attributes()->include;
27-
if (file_exists(__DIR__ . '/../' . $include)) {
28-
require __DIR__ . '/../' . $include;
29-
}
30-
}
3127

32-
$launcher = Launcher::getLauncher();
33-
$launcher->workspace(dirname(__DIR__));
34-
$launcher->namespace((string)$namespace);
35-
$launcher->entryPoint((string)$entrypoint);
36-
$launcher->launch();
28+
// Gets the console arguments without command name
29+
$args = $GLOBALS['argv'] ?? [];
30+
array_shift($args);
31+
32+
// Initialize and launch the application
33+
$launcher = Launcher::initialize($root . '/devnet.proj');
34+
$launcher->launch($args);

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "devnet/console-template",
3-
"description": "DevNet Console Application",
4-
"type": "devnet-project",
3+
"description": "Console Application",
4+
"type": "project",
55
"license": "MIT",
66
"minimum-stability": "dev",
77
"prefer-stable": true

devnet.proj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0"?>
2+
<Project>
3+
<Properties>
4+
<StartupObject>Application\Program</StartupObject>
5+
</Properties>
6+
<Items>
7+
<CodeFile include="vendor/autoload.php"/>
8+
</Items>
9+
</Project>

project.phproj

Lines changed: 0 additions & 10 deletions
This file was deleted.

Program.php renamed to src/Program.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ class Program
88
{
99
public static function main(array $args = [])
1010
{
11-
Console::writeline("Hello World!");
11+
Console::writeLine("Hello World!");
1212
}
1313
}

0 commit comments

Comments
 (0)