friendsofhyperf / closure-command
This package is abandoned and no longer maintained.
The author suggests using the hyperf/command package instead.
The closure command component for Hyperf.
Package info
github.com/friendsofhyperf/closure-command
pkg:composer/friendsofhyperf/closure-command
v3.1.0
2023-11-30 14:25 UTC
Requires
- hyperf/collection: ~3.1.0
- hyperf/command: ~3.1.0
- hyperf/context: ~3.1.0
- hyperf/di: ~3.1.0
- hyperf/event: ~3.1.0
- hyperf/stringable: ~3.1.0
- hyperf/support: ~3.1.0
- hyperf/tappable: ~3.1.0
This package is auto-updated.
Last update: 2024-02-27 00:47:24 UTC
README
The closure command component for Hyperf.
⚠️ This component is deprecated, please use hyperf/command instead.
Installation
composer require friendsofhyperf/closure-command
Publish
php bin/hyperf.php vendor:publish friendsofhyperf/closure-command
Usage
- Define ClosureCommand
// config/console.php use FriendsOfHyperf\ClosureCommand\Console; use FriendsOfHyperf\ClosureCommand\Inspiring; Console::command('inspire', function () { $this->comment(Inspiring::quote()); })->describe('Display an inspiring quote'); Console::command('foo:bar', function() { $this->info('Command foo:bar executed.'); })->describe('Description of command foo::bar');
- Define AnnotationCommand
<?php namespace App\Service; use FriendsOfHyperf\ClosureCommand\Annotation\Command; use FriendsOfHyperf\ClosureCommand\Output; use Hyperf\Di\Annotation\Inject; #[Command(signature: 'foo:bar1', handle: 'bar1', description: 'The description of foo:bar1 command.')] #[Command(signature: 'foo', description: 'The description of foo command.')] class FooService { use \Hyperf\Command\Concerns\InteractsWithIO; #[Command(signature: 'foo:bar {--bar=1 : Bar Value}', description: 'The description of foo:bar command.')] public function bar($bar) { $this->output?->info('Bar Value: ' . $bar); return $bar; } public function bar1() { $this->output?->info(__METHOD__); } public function handle() { $this->output?->info(__METHOD__); } }
Run php bin/hyperf.php
foo foo:bar The description of foo:bar command. foo:bar1 The description of foo:bar1 command.