php - Target class [AppListenersCartUpdatedListener] does not exist
Get the solution ↓↓↓i want to configure events in choping cart uses LaravelShoppingcart package, i run cmd followingphp artisan make: listener CartUpdateListener
, but it gives me errorTarget class [App \ Listeners \ CartUpdatedListener] does not exist
.
EventServiceProvider.php
protected $listen = [
'cart.added' => [
'App\Listeners\CartUpdatedListener',
],
'cart.updated' => [
'App\Listeners\CartUpdatedListener',
],
'cart.removed' => [
'App\Listeners\CartUpdatedListener',
],
];
CartUpdateListener.php
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event)
{
dd("event was fired");
}
Answer
Solution:
Your error tells us aboutCardUpdatedListener
but your file name isCardUpdateListener
(an extra 'd' in the word Update). Check it, or post full class code.
Answer
Solution:
When you run an Artisan command, it bootstraps a Laravel app. Among a lot of things, event listeners are setup and they need to be constructed, but at this moment, your listener class does not exist yet. Follow these steps:
Remove everything from your
listen
property ofEventServiceProvider
Run
php artisan make:listener CartUpdatedListener
Refill your
listen
property
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: dompdf image not found or type unknown
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.