-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathGenerateMiddlewareCommand.php
More file actions
40 lines (31 loc) · 867 Bytes
/
GenerateMiddlewareCommand.php
File metadata and controls
40 lines (31 loc) · 867 Bytes
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
<?php
declare(strict_types=1);
namespace Bow\Console\Command\Generator;
use Bow\Console\AbstractCommand;
use Bow\Console\Color;
use Bow\Console\Generator;
class GenerateMiddlewareCommand extends AbstractCommand
{
/**
* Add middleware
*
* @param string $middleware
* @return void
*/
public function run(string $middleware): void
{
$generator = new Generator(
$this->setting->getMiddlewareDirectory(),
$middleware
);
if ($generator->fileExists()) {
echo Color::red("The middleware already exists");
exit(1);
}
$generator->write('middleware', [
'baseNamespace' => $this->namespaces['middleware'] ?? "App\\Middlewares"
]);
echo Color::green("The middleware has been well created.");
exit(0);
}
}