问题
I'm deploying using envoyer as usual. The one caveat is that during my local host development (and while i was switching git branches).. I faced this error:
[ReflectionException] Class App\Http\Controllers\Admin\BatchUpdateStoresController does not exist
I solved it by clearing the routes cache (see details here).
The problem now is that when I deployed on envoyer.. I'm getting this error on the nginx logs:
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/
I tried deleting the /home/forge/default/envoyer/releases/20180306221058/bootstrap
folder all together.. but that made it only worse (ie i wasn't even getting nginx error logs anymore).
what do I do?
回答1:
it turns out that i add a library to composer and added its service provider and alias to config/app.php like so:
'providers' => [
..
Clockwork\Support\Laravel\ClockworkServiceProvider::class,
'aliases' => [
..
'Clockwork' => Clockwork\Support\Laravel\Facade::class,
but then later on removed that library from composer (b/c i stopped using it) and forgot to update the service provider.
Updating the service provider solved the problem.
Bonus
I got the same problem again from one of my engineers working on a Pull Request that has like 100 commits in it (it's a topic branch.. please don't judge).
He affirmed that all the libraries are used.
So what I did is that I simply ran a git diff on two specific files only amongst that large range: config/app.php
and composer.json
like so:
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,
],
];
so the problem was clear: basically we're including "orangehill/iseed": "2.2",
as a require-dev
requirement, but not checking if the env is dev when we register it as a service provider.. so it blew up.
so this fixed it inside of 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);
}
}
}
bonus 2
sometimes you have to remove the entire bootstrap directory
rm -rf bootstrap
then run
composer dump-autoload
but laravel won't work after that, so you must git revert the change of deleting all of bootstrap (which should be in your git repo anyways).. and you're golden after that
回答2:
I encountered the missing Hash
class exception after upgrading to 5.6. The problem was an overlooked step in the upgrade guide:
All hashing configuration is now housed in its own config/hashing.php configuration file. You should place a copy of the default configuration file in your own application. Most likely, you should maintain the bcrypt driver as your default driver. However, argon is also supported.
来源:https://stackoverflow.com/questions/49141040/uncaught-reflectionexception-class-hash-does-not-exist-in-envoyer-deploy