spatie / laravel-webhook-client

Receive webhooks in Laravel apps
https://freek.dev/1383-sending-and-receiving-webhooks-in-laravel-apps
MIT License
1k stars 147 forks source link

App\Http\Controllers\Spatie\WebhookClient\Http\Controllers\WebhookController was not found #138

Closed kartman5 closed 2 years ago

kartman5 commented 2 years ago

Hi,

After upgrading this package to the 3.1.0 package not working properly.

This throw WebhookController was not found error.

How can I resolve this issue?

Thanks.

freekmurze commented 2 years ago

That namespace is wrong. Use\Spatie\WebhookClient\Http\Controllers\WebhookController

kartman5 commented 2 years ago

I know it's a namespace error, but this error comes after updating in laravel 9.

kartman5 commented 2 years ago

image

Above error message comes when doing a composer update and all other PHP artisan commands.

ankurk91 commented 2 years ago

The error is coming because of this line

https://github.com/spatie/laravel-webhook-client/blob/0e078c1af500b573e5693faf5d480b1a88fc1aad/src/WebhookClientServiceProvider.php#L25

Package should define controller like

return Route::post($url, '\Spatie\WebhookClient\Http\Controllers\WebhookController')->name("webhook-client-{$name}");

otherwise laravel will unable to find the controller when the macro is inside a group like

Route::group(['namespace'=> 'MyPath\Folder'], function() {
    Route::webhook("my-webhhok");
});

@freekmurze Would you accept a PR ?

Similar PR was send https://github.com/spatie/laravel-stripe-webhooks/pull/100

freekmurze commented 2 years ago

@ankurk91 Yup, send a PR 👍