运行artisan命令时出现Bugsnag错误

时间:2016-05-27 08:45:44

标签: laravel bugsnag

尝试在我的生产服务器上运行php artisan migrate时出现此错误...

PHP Fatal error:  Uncaught exception 'Exception' with message 'Bugsnag Error: Invalid API key' in /var/app/current/vendor/bugsnag/bugsnag/src/Bugsnag/Client.php:19
Stack trace:
#0 /var/app/current/vendor/bugsnag/bugsnag-laravel/src/Bugsnag/BugsnagLaravel/BugsnagLaravelServiceProvider.php(61): Bugsnag_Client->__construct(NULL)
#1 /var/app/current/vendor/laravel/framework/src/Illuminate/Container/Container.php(738): Bugsnag\BugsnagLaravel\BugsnagLaravelServiceProvider->Bugsnag\BugsnagLaravel\{closure}(Object(Illuminate\Foundation\Application), Array)
#2 /var/app/current/vendor/laravel/framework/src/Illuminate/Container/Container.php(631): Illuminate\Container\Container->build(Object(Closure), Array)
#3 /var/app/current/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(674): Illuminate\Container\Container->make('bugsnag', Array)
#4 /var/app/current/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(62): Illuminate\Foundation\Application->make('bugsnag', Array)
#5 /var/app/current/vendor/bugsnag/bugsna in /var/app/current/vendor/bugsnag/bugsnag/src/Bugsnag/Client.php on line 19
PHP Fatal error:  Uncaught exception 'Exception' with message 'Bugsnag Error: Invalid API key' in /var/app/current/vendor/bugsnag/bugsnag/src/Bugsnag/Client.php:19
Stack trace:
#0 /var/app/current/vendor/bugsnag/bugsnag-laravel/src/Bugsnag/BugsnagLaravel/BugsnagLaravelServiceProvider.php(61): Bugsnag_Client->__construct(NULL)
#1 /var/app/current/vendor/laravel/framework/src/Illuminate/Container/Container.php(738): Bugsnag\BugsnagLaravel\BugsnagLaravelServiceProvider->Bugsnag\BugsnagLaravel\{closure}(Object(Illuminate\Foundation\Application), Array)
#2 /var/app/current/vendor/laravel/framework/src/Illuminate/Container/Container.php(631): Illuminate\Container\Container->build(Object(Closure), Array)
#3 /var/app/current/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(674): Illuminate\Container\Container->make('bugsnag', Array)
#4 /var/app/current/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(62): Illuminate\Foundation\Application->make('bugsnag', Array)
#5 /var/app/current/vendor/bugsnag/bugsna in /var/app/current/vendor/bugsnag/bugsnag/src/Bugsnag/Client.php on line 19

我在命令行上运行了env,我有一个名为BUGSNAG_API_KEY的env变量,它的值与bugsnag.com上的密钥完全匹配。

此外,我在./config/bugsnag.php

的项目中有这一行

'api_key' => env('BUGSNAG_API_KEY'),

奇怪的是,我最终再次尝试了相同的命令(php artisan migrate)并且它有效!但它让我非常不安,因为它是一台生产服务器。所以我想了解这个问题。

顺便说一下,错误似乎也在登录Bugsnag。

2 个答案:

答案 0 :(得分:1)

尝试使用php artisan config:cache重新生成配置缓存。它将使用.env文件中的当前数据生成新的配置缓存。这对我有用。

答案 1 :(得分:0)

以防万一...

Bugsnag Git Repo提到了此问题:

({Uncaught exception 'ReflectionException' with message 'Class bugsnag.logger does not exist'

Github用户GrahamCampbell建议实际发生的是存在另一个错误,但是这是“ ...试图登录到bugsnag导致此错误,这隐藏了真正的错误”。我通过执行用户russianryebread的建议来确认这是我的问题,该建议是将bugsnag.php配置文件手动复制到Laravel / config目录中。一旦完成此操作,现在我的真正错误就会显示:

[Symfony \ Component \ Debug \ Exception \ FatalThrowableError]解析错误:语法错误,意外的'{'

现在要解决此问题:)

希望这会有所帮助!