Removed framework dependency of di, command and dispatcher.

This commit is contained in:
李铭昕 2019-06-25 20:53:28 +08:00
parent bf3617acd5
commit d619fa7033
3 changed files with 16 additions and 20 deletions

View File

@ -16,23 +16,23 @@
"php": ">=7.2",
"ext-swoole": ">=4.3",
"fig/http-message-util": "^1.1.2",
"hyperf/contract": "~1.0.0",
"hyperf/utils": "~1.0.0",
"psr/container": "^1.0",
"psr/event-dispatcher": "^1.0",
"psr/log": "^1.0",
"hyperf/command": "~1.0.0",
"hyperf/contract": "~1.0.0",
"hyperf/di": "~1.0.0",
"hyperf/dispatcher": "~1.0.0",
"hyperf/utils": "~1.0.0"
"psr/log": "^1.0"
},
"require-dev": {
"doctrine/common": "@stable",
"friendsofphp/php-cs-fixer": "^2.9",
"malukenho/docheader": "^0.1.6",
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^7.0.0",
"friendsofphp/php-cs-fixer": "^2.9",
"doctrine/common": "@stable"
"phpunit/phpunit": "^7.0.0"
},
"suggest": {
"hyperf/di": "Required to use Command annotation.",
"hyperf/dispatcher": "Required to use BootApplication event.",
"hyperf/command": "Required to use Command annotation."
},
"autoload": {
"files": [

View File

@ -32,8 +32,12 @@ class ApplicationFactory
$config = $container->get(ConfigInterface::class);
$commands = $config->get('commands', []);
// Append commands that defined by annotation.
$annotationCommands = AnnotationCollector::getClassByAnnotation(Command::class);
$annotationCommands = array_keys($annotationCommands);
$annotationCommands = [];
if (class_exists(AnnotationCollector::class) && class_exists(Command::class)) {
$annotationCommands = AnnotationCollector::getClassByAnnotation(Command::class);
$annotationCommands = array_keys($annotationCommands);
}
$commands = array_unique(array_merge($commands, $annotationCommands));
$application = new Application();
foreach ($commands as $command) {

View File

@ -13,22 +13,15 @@ declare(strict_types=1);
namespace Hyperf\Framework\Bootstrap;
use Hyperf\Contract\StdoutLoggerInterface;
use Hyperf\Di\Container;
use Hyperf\Framework\Event\AfterWorkerStart;
use Hyperf\Framework\Event\BeforeWorkerStart;
use Hyperf\Framework\Event\MainWorkerStart;
use Hyperf\Framework\Event\OtherWorkerStart;
use Psr\Container\ContainerInterface;
use Psr\EventDispatcher\EventDispatcherInterface;
use Swoole\Server as SwooleServer;
class WorkerStartCallback
{
/**
* @var Container
*/
private $container;
/**
* @var StdoutLoggerInterface
*/
@ -39,9 +32,8 @@ class WorkerStartCallback
*/
private $eventDispatcher;
public function __construct(ContainerInterface $container, StdoutLoggerInterface $logger, EventDispatcherInterface $eventDispatcher)
public function __construct(StdoutLoggerInterface $logger, EventDispatcherInterface $eventDispatcher)
{
$this->container = $container;
$this->logger = $logger;
$this->eventDispatcher = $eventDispatcher;
}