我有這個(gè)簡(jiǎn)單的控制臺(tái)程序:namespace MyApp\Console;use Symfony\Component\Console\Command\Command;use Symfony\Component\Console\Input\InputArgument;class MaConsole extends Command { protected function configure() { $this->setDescription('Console\'s not console'); } protected function execute( \Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output ) { $output->writeln('Doing Stuff'); }}我像這樣加載它:namespace MyApp;use Symfony\Component\Console\Application as SymfonyApplication;use MyApp\Console\MaConsole;class Application extends SymfonyApplication{ public function __construct( string $name = 'staff', string $version = '0.0.1' ) { parent::__construct($name, $version); throw new \Exception('Test Sentry on Playground'); $this->add(new MaConsole()); }}我想在 Sentry 服務(wù)中記錄上面拋出的異常。所以我的切入點(diǎn)是:use MyApp\Application;require __DIR__ . '/vendor/autoload.php';Sentry\init([ 'dsn' => getenv('SENTRY_DSN'), 'environment' => getenv('ENVIRONMENT')]);$application = (new Application())->run();但是我沒(méi)有將錯(cuò)誤記錄到哨兵中,即使我已經(jīng)設(shè)置了正確的環(huán)境變量。該應(yīng)用程序不加載完整的 Symfony 框架,而是僅使用控制臺(tái)組件,所以我不知道是否應(yīng)該使用 Sentry Symfony 集成:https : //docs.sentry.io/platforms/php/symfony/原因是因?yàn)槲也恢涝谖业那闆r下如何加載包,因此我使用 SDK。
在 Symfony 控制臺(tái)程序上啟用 Sentry 而不安裝整個(gè) symfony
慕桂英3389331
2021-12-24 15:15:23