4

我像往常一样使用 envoyer 进行部署。需要注意的是,在我的本地主机开发过程中(当我切换 git 分支时).. 我遇到了这个错误:

[ReflectionException] 类 App\Http\Controllers\Admin\BatchUpdateStoresController 不存在

我通过清除路由缓存解决了它(请参阅 此处的详细信息)。

现在的问题是,当我在 envoyer 上部署时。我在 nginx 日志上收到此错误:

PHP message: PHP Fatal error:  Uncaught ReflectionException: Class hash does not exist in /home/forge/default/envoyer/releases/20180306221058/bootstrap/cache/compiled.php:1479
Stack trace:
#0 /home/forge/default/envoyer/releases/20180306221058/bootstrap/cache/compiled.php(1479): ReflectionClass->__construct('hash')
#1 /home/forge/default/envoyer/releases/20180306221058/bootstrap/cache/compiled.php(1433): Illuminate\Container\Container->build('hash', Array)
#2 /home/forge/default/envoyer/releases/20180306221058/bootstrap/cache/compiled.php(2011): Illuminate\Container\Container->make('hash', Array)
#3 /home/forge/default/envoyer/releases/20180306221058/bootstrap/cache/compiled.php(1686): Illuminate\Foundation\Application->make('hash')
#4 /home/forge/default/envoyer/releases/20180306221058/bootstrap/cache/compiled.php(524): Illuminate\Container\Container->offsetGet('hash')
#5 /home/forge/default/envoyer/releases/20180306221058/bootstrap/

我尝试将文件夹全部删除/home/forge/default/envoyer/releases/20180306221058/bootstrap.. 但这只会让情况变得更糟(即我什至没有收到 nginx 错误日志了)。

我该怎么办?

4

2 回答 2

3

事实证明,我向作曲家添加了一个,并将其服务提供者和别名添加到 config/app.php,如下所示:

'providers'       => [
 ..
    Clockwork\Support\Laravel\ClockworkServiceProvider::class,

'aliases'         => [ 
..
    'Clockwork'        => Clockwork\Support\Laravel\Facade::class,

但后来从作曲家中删除了该库(b/ci 停止使用它)并忘记更新服务提供者。

更新服务提供商解决了这个问题。

奖金

我的一位工程师在处理一个包含 100 次提交的拉取请求时再次遇到了同样的问题(这是一个主题分支..请不要判断)。

他肯定所有的图书馆都被使用了。

所以我所做的是我只是在那个大范围内对两个特定文件运行了 git diff:就像这样config/app.phpcomposer.json

作曲家.json

$ git diff 96d397a bce2052 composer.json
diff --git a/composer.json b/composer.json
index 4c16f388..d780ec01 100644
--- a/composer.json
+++ b/composer.json
@@ -4,6 +4,12 @@
     "keywords": ["framework", "laravel"],
     "license": "MIT",
     "type": "project",
+    "repositories": [
+        {
+            "type": "vcs",
+            "url":  "https://github.com/abbood/translation"
+        }
+    ],
     "require": {
         "php": ">=5.5.9",
         "laravel/framework": "5.3.*",
@@ -26,7 +32,9 @@
         "aloha/twilio": "^2.1",
         "laravel/socialite": "^2.0",
         "barryvdh/laravel-dompdf": "^0.8.0",
-        "mockery/mockery": "1.0"
+        "mockery/mockery": "1.0",
+        "maxmind-db/reader": "~1.0",
+        "waavi/translation": "dev-extractGenCode"
     },
     "require-dev": {
         "symfony/dom-crawler": "~3.1",
@@ -35,6 +43,7 @@
         "phpunit/phpunit": "~5.0",
         "phpspec/phpspec": "~2.1",
         "johnkary/phpunit-speedtrap": "^1.0",
+        "orangehill/iseed": "2.2",
         "barryvdh/laravel-ide-helper": "^2.4"
     },
     "autoload": {

配置/app.php

git diff 96d397a bce2052 config/app.php
diff --git a/config/app.php b/config/app.php
index 5025f79b..28e34794 100644
--- a/config/app.php
+++ b/config/app.php
@@ -10,8 +10,8 @@ return [
     | the framework needs to place the application's version in a notification
     | or any other location as required by the application or its packages.
     */
+    'version' => '1.3.57',

-    'version' => '1.3.46',

     'env' => env('APP_ENV', 'production'),

@@ -115,6 +115,17 @@ return [
     /*those options are overriden in bootstrap/app for info.log and error.log*/
     'log'             => 'daily',

+    /*
+    |--------------------------------------------------------------------------
+    | MaxMind mmdb Path
+    |--------------------------------------------------------------------------
+    |
+    | Here you specify the path to MaxMind GeoLite2-City.mmdb
+    |
+    |
+    */
+    'maxmindDB'             => env('APP_MAX_MIND_MMDB', "./maxmind/GeoLite2-City.mmdb"),
+
     /*
     |--------------------------------------------------------------------------
     | Autoloaded Service Providers
@@ -149,7 +160,6 @@ return [
         Illuminate\Redis\RedisServiceProvider::class,
         Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
         Illuminate\Session\SessionServiceProvider::class,
-        Illuminate\Translation\TranslationServiceProvider::class,
         Illuminate\Validation\ValidationServiceProvider::class,
         Illuminate\View\ViewServiceProvider::class,

@@ -180,7 +190,10 @@ return [
         Davibennun\LaravelPushNotification\LaravelPushNotificationServiceProvider::class,
         Aloha\Twilio\Support\Laravel\ServiceProvider::class,
         Laravel\Socialite\SocialiteServiceProvider::class,
+        Orangehill\Iseed\IseedServiceProvider::class,
         Barryvdh\DomPDF\ServiceProvider::class,
+        Waavi\Translation\TranslationServiceProvider::class,
+
     ],
     /*
     |--------------------------------------------------------------------------
@@ -239,6 +252,8 @@ return [
         'Raven'            => Jenssegers\Raven\Facades\Raven::class,
         'Socialite'        => Laravel\Socialite\Facades\Socialite::class,
         'PDF'              => Barryvdh\DomPDF\Facade::class,
+        'UriLocalizer'     => \Waavi\Translation\Facades\UriLocalizer::class,
+        'TranslationCache' => \Waavi\Translation\Facades\TranslationCache::class,
     ],

 ];

所以问题很清楚:基本上我们将"orangehill/iseed": "2.2",其作为一项require-dev要求包括在内,但在我们将其注册为服务提供者时不检查 env 是否为 dev .. 所以它爆炸了。

所以这把它固定在里面app/Providers/AppServiceProvider.php

namespace App\Providers;


use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{


    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        $env = config('app.env');



        if ($env === 'local' || $env === 'testing') {
            .. dev only libraries
            $this->app->register(\Orangehill\Iseed\IseedServiceProvider::class);
        }
    }


}

奖金 2

有时您必须删除整个引导目录

rm -rf bootstrap

然后运行

composer dump-autoload

但是之后 laravel 将无法工作,因此您必须 git revert 删除所有引导程序的更改(无论如何都应该在您的 git repo 中).. 之后您就很成功了

在此处输入图像描述

于 2018-03-07T07:36:47.477 回答
1

Hash升级到 5.6 后遇到了缺失类异常。问题是升级指南中被忽略的一步:

所有散列配置现在都存放在它自己的 config/hashing.php 配置文件中。您应该将默认配置文件的副本放在您自己的应用程序中。最有可能的是,您应该将 bcrypt 驱动程序作为您的默认驱动程序。但是,也支持氩气。

于 2018-03-07T05:01:57.550 回答