X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=bin%2Fconsole.php;h=b797e6ba99a5d7800c5782eef97b8e18cc28d804;hb=35cf140cb27fd09730741c9162204ec697d09001;hp=757af31d5d750850187acfc19f6bcb44bb7e5bb3;hpb=cb1ad4287d114ef3c712aa2d163a7f80e9bd48f1;p=friendica.git diff --git a/bin/console.php b/bin/console.php index 757af31d5d..b797e6ba99 100755 --- a/bin/console.php +++ b/bin/console.php @@ -1,19 +1,45 @@ #!/usr/bin/env php . + * + */ -require dirname(__DIR__) . '/vendor/autoload.php'; +if (php_sapi_name() !== 'cli') { + header($_SERVER["SERVER_PROTOCOL"] . ' 403 Forbidden'); + exit(); +} + +use Dice\Dice; +use Friendica\Core\Logger\Capability\LogChannel; +use Friendica\DI; +use Psr\Log\LoggerInterface; -use Friendica\Core\Config; -use Friendica\Factory; -use Friendica\Util\BasePath; +require dirname(__DIR__) . '/vendor/autoload.php'; -$basedir = BasePath::create(dirname(__DIR__), $_SERVER); -$configLoader = new Config\ConfigCacheLoader($basedir); -$config = Factory\ConfigFactory::createCache($configLoader); -$logger = Factory\LoggerFactory::create('console', $config); -$profiler = Factory\ProfilerFactory::create($logger, $config); +$dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php'); +/** @var \Friendica\Core\Addon\Capability\ICanLoadAddons $addonLoader */ +$addonLoader = $dice->create(\Friendica\Core\Addon\Capability\ICanLoadAddons::class); +$dice = $dice->addRules($addonLoader->getActiveAddonConfig('dependencies')); +$dice = $dice->addRule(LoggerInterface::class, ['constructParams' => [LogChannel::CONSOLE]]); -$a = new Friendica\App($config, $logger, $profiler); -\Friendica\BaseObject::setApp($a); +/// @fixme Necessary until Hooks inside the Logger can get loaded without the DI-class +DI::init($dice); +\Friendica\Core\Logger\Handler\ErrorHandler::register($dice->create(\Psr\Log\LoggerInterface::class)); -(new Friendica\Core\Console($argv))->execute(); +(new Friendica\Core\Console($dice, $argv))->execute();