-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathrendered.xml
91 lines (83 loc) · 2.91 KB
/
rendered.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?xml version="1.0" encoding="UTF-8"?>
<document xmlns="http://commonmark.org/xml/1.0">
<paragraph>
<code>tempest/console</code>
<text> is a standalone package used to build console applications. </text>
<link destination="https://github.com/tempestphp/tempest-console" title="">
<strong>
<text>Give it a ⭐️ on GitHub</text>
</strong>
</link>
<text>!</text>
</paragraph>
<paragraph>
<text>You can install </text>
<code>tempest/console</code>
<text> like so:</text>
</paragraph>
<code_block>composer require tempest/console:1.0-alpha.5
</code_block>
<paragraph>
<text>And run it like so:</text>
</paragraph>
<code_block info="php">{:hl-comment:#!/usr/bin/env php:}
<?php
use Tempest\Console\ConsoleApplication;
require_once __DIR__ . '/vendor/autoload.php';
ConsoleApplication::boot()->run();
</code_block>
<heading level="2">
<text>Configuration</text>
<custom_inline_headingpermalink slug="configuration" />
</heading>
<paragraph>
<code>tempest/console</code>
<text> uses on Tempest's discovery to find and register console commands. That means you don't have to register any commands manually, and any method within your codebase using the </text>
<code>{php}#[ConsoleCommand]</code>
<text> attribute will automatically be discovered by your console application.</text>
</paragraph>
<code_block info="php">// app/InteractiveCommand.php
use Tempest\Console\Console;
use Tempest\Console\ConsoleCommand;
final readonly class InteractiveCommand
{
public function __construct(
private Console $console,
) {}
#[ConsoleCommand('hello:world')]
public function __invoke(): void
{
$this->console->writeln('Hello World!');
}
}
</code_block>
<paragraph>
<text>Tempest will discover all console commands within namespaces configured as composer PSR-4 autoload namespaces, as well as all third-party packages that require Tempest.</text>
</paragraph>
<code_block info="json">"autoload": {
"psr-4": {
"App\\": "app/"
}
},
</code_block>
<paragraph>
<text>In case you need more fine-grained control over which directories to discover, you can provide a custom </text>
<code>{php}AppConfig</code>
<text> instance to the </text>
<code>{php}ConsoleApplication::boot()</code>
<text> method:</text>
</paragraph>
<code_block info="php">use Tempest\AppConfig;
use Tempest\Core\DiscoveryLocation;
use Tempest\Console\ConsoleApplication;
$appConfig = new AppConfig(
discoveryLocations: [
new DiscoveryLocation(
namespace: 'App\\',
path: __DIR__ . '/app/',
),
],
);
ConsoleApplication::boot(appConfig: $appConfig)->run();
</code_block>
</document>