After updating my project from Laravel v5.7.11 to v6.0.3, I received the following error at the end of the composer update
:
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDum
@php artisan package:discover
InvalidArgumentException : Unable to find observer: App\Observer\ClientObserver
at /usr/local/var/www/system-panel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasEvents.php:86
82| if (class_exists($class)) {
83| return $class;
84| }
85|
> 86| throw new InvalidArgumentException('Unable to find observer: '.$class);
87| }
88|
89| /**
90| * Get the observable event names.
Exception trace:
1 Illuminate\Database\Eloquent\Model::resolveObserverClassName("App\Observer\ClientObserver")
/usr/local/var/www/system-panel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasEvents.php:56
2 Illuminate\Database\Eloquent\Model::registerObserver("App\Observer\ClientObserver")
/usr/local/var/www/system-panel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasEvents.php:42
The ClientObserver class is sitting in the Observers directory within the App directory. App/Observers/ClientObserver
The client observer is defined as follows:
<?php
namespace App\Observers;
use App\Models\Passport\Client;
use Uuid;
class ClientObserver
{
....
}
I expected the function to run as previously, without issue. Nothing has been changed besides the updating of the packages.
The php artisan
also no longer works, it returns the same error.
Has anyone had this issue, and if so what was the fix?
The issue was in my AppServiceProvider.php
. The use statements were referencing singular App\Observer
rather than the expected directory name App\Observers
where the ClientObserver is located.
Once updated the command ran without error.