未捕获的ReflectionException:使者部署中不存在类哈希 - php

我像往常一样使用envoyer进行部署。一个警告是,在我本地主机开发期间(以及在我切换git分支时)..我遇到了这个错误:

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

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

现在的问题是,当我在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错误日志)。

我该怎么办?

参考方案

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

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

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

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

更新服务提供商可以解决此问题。

奖金

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

他确认所有库均已使用。

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

Composer.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": {

config / 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要求包括在内,但在将其注册为服务提供者时不检查环境是否是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恢复还原删除所有引导程序的更改(无论如何,该引导程序应该在您的git repo中)..

未捕获的ReflectionException:使者部署中不存在类哈希 - php

如何从php中获取datatables jQuery插件的json数据 - php

我是PHP的新手,正在尝试使用Datatables jQuery插件。我知道我必须从.php文件中获取数据,然后在数据表中使用它,但是我似乎无法通过ajax将其传递给数据表。我设法从数据库中获取数据,并对其进行json编码,但是后来我不知道如何在我的index.php文件中调用它,并在其中显示它。我究竟做错了什么?这是我的代码:HTML(已编辑): <…

PHP:将数组值加在一起 - php

我相信这比标题听起来要难一些,但我可能完全错了。我有一个像这样的数组:[["londrina",15],["cascavel",34],["londrina",23],['tiradentes',34],['tiradentes',21]] 我希望能够采用通用…

PHP JQuery复选框 - php

我有以下片段。 var myData = { video: $("input[name='video[]']:checked").serialize(), sinopse: $("#sinopse").val(), dia: $("#dia").val(), quem: $(&#…

如何preg_replace特殊字符(例如“Prêt-à-porter”)? - php

在这个论坛和一般的网络上,都有很多关于此的问答。但是我不只是得到它。这是我的代码:function updateGuideKeywords($dal) { $pattern = "/[^a-zA-Z-êàé]/"; $keywords = preg_replace($pattern, '', $_POST['…

代码未在服务器目录php中创建文件 - php

我正在尝试使用以下代码将新文件写入服务器error_reporting(E_ALL); ini_set('display_errors', 1); if($_SERVER['REQUEST_METHOD'] == "POST") { $html = $_POST['html'];…