successdav's avatar

New Event doesn't fire in production

I have my event setup and everything works fine on local development, However on production server, the event is is not fired

Where the event is fired

    foreach ($loans as $loan) {
            if ($loan->isOverDue()) {
				//dd('event is triggered
                OverdueLoan::dispatch($loan);
            }
        }

On the OverdueLoan.php Event I added a dump statement to know if the event is fired

     */
    public function __construct(Loan $loan)
    {
        dd('Overdue Event is called');
        $this->loan = $loan;
    }

on local development the dd statement is called, however on the production server it never reaches the dump statement which I assump the event is not been fired.

0 likes
6 replies
successdav's avatar

I replace the dd statement with Log statement, and it turns out the OverdueLoan event is actually firing, but the listener is not responding, Event service provider code

    protected $listen = [
        Registered::class => [
            SendEmailVerificationNotification::class,
        ],
        PaymentAdded::class => [
            AddTransactionHistory::class,
            UpdateLoanStatus::class,
        ],
        UserMadeFirstSavings::class => [
            AwardReferralBonus::class,
            AwardWelcomeBonus::class
        ],
        LoanIsDue::class => [
            SendDueMessage::class,
        ],
        LoanDueDateIsExtended::class => [
            AdjustRepaymentPlans::class
        ],
        WalletIsCredited::class => [
            AwardReferralBonus::class,
        ],
        OverdueLoan::class => [
            HandleLoanOverdue::class
        ],
    ];
tykus's avatar

@successdav are you using the correct FQCN for the event (and listener) in the EventServiceProvider, e.g.

use App\Events\OverdueLoan;
use App\Listeners\HandleLoanOverdue;
successdav's avatar

Yes, I have these two correct

use App\Events\OverdueLoan;
use App\Listeners\HandleLoanOverdue;

Everything works find on local development, On the production I have cleared all cache and dump-autoload, but not luck

tykus's avatar
tykus
Best Answer
Level 104

@successdav did you cache events on the production server? Try clearing the events cache

php artisan event:clear

Please or to participate in this conversation.