laravel / slack-notification-channel

Slack Notification Channel for laravel.
https://laravel.com/docs/notifications#slack-notifications
MIT License
856 stars 59 forks source link

Driver [slack] not supported. #14

Closed rjchauhan closed 5 years ago

rjchauhan commented 5 years ago

Description:

I've upgraded Laravel version from 5.7 to 5.8 and installed slack notification channel package via composer. But somehow slack notifications stopped working. composer dumpautoload discovers this package but seems like it's not registering slack notification channel.

I've traced the code with xdebug and found that createSlackDriver() method is not found on laravel/framework/src/Illuminate/Support/Manager.php:95. Due to this "Driver [slack] not supported" exception occurs.

image

driesvints commented 5 years ago

This shouldn't be necessary anymore since the service provider now registers the slack channel: https://github.com/laravel/slack-notification-channel/blob/2.0/src/SlackChannelServiceProvider.php

rjchauhan commented 5 years ago

Yes, It just works fine and registers slack channel auto if I setup fresh Laravel 5.8. But the above issue occurs on my older projects where I upgrade Laravel from 5.7 to 5.8.

yehudahkay commented 5 years ago

I have the same issue on a fresh installation

yehudahkay commented 5 years ago

I ran composer require on local and then pushed those changes. I found that running it on the server fixed the issue. Here is the diff after running on the server.

image

driesvints commented 5 years ago

Yes, It just works fine and registers slack channel auto if I setup fresh Laravel 5.8. But the above issue occurs on my older projects where I upgrade Laravel from 5.7 to 5.8.

@rjchauhan then there's something that's not updated to the project when upgrading. We need to figure out what. Have you followed every step in the upgrade guides?

https://laravel.com/docs/5.7/upgrade https://laravel.com/docs/5.8/upgrade

@yehudahkay that diff doesn't seems to be related to this issue but a file permissions thing?

yehudahkay commented 5 years ago

It wasn't working with push from local. I then tried require on the server which made those 4 permission changes and it started working.

rjchauhan commented 5 years ago

image

Yes I've followed every step in the upgrade guide and double checked :)

Laravel is on v5.8.9 and I've also tried installing composer dependencies by removing composer.lock file.

driesvints commented 5 years ago

@rjchauhan does this problem occurs for you on a fresh installation?

rjchauhan commented 5 years ago

Nope, Fresh installation works just fine! with same slack channel and same dependencies version.

driesvints commented 5 years ago

@rjchauhan then there's definitely something wrong with your specific installation. Have you updated the skeleton with all the changes from 5.8? Can you copy/paste your config/app.php config file?

rjchauhan commented 5 years ago
<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Application Name
    |--------------------------------------------------------------------------
    |
    | This value is the name of your application. This value is used when the
    | framework needs to place the application's name in a notification or
    | any other location as required by the application or its packages.
    |
    */

    'name' => env('APP_NAME', 'Laravel'),

    /*
    |--------------------------------------------------------------------------
    | Application Environment
    |--------------------------------------------------------------------------
    |
    | This value determines the "environment" your application is currently
    | running in. This may determine how you prefer to configure various
    | services your application utilizes. Set this in your ".env" file.
    |
    */

    'env' => env('APP_ENV', 'production'),

    /*
    |--------------------------------------------------------------------------
    | Application Debug Mode
    |--------------------------------------------------------------------------
    |
    | When your application is in debug mode, detailed error messages with
    | stack traces will be shown on every error that occurs within your
    | application. If disabled, a simple generic error page is shown.
    |
    */

    'debug' => env('APP_DEBUG', false),

    /*
    |--------------------------------------------------------------------------
    | Application URL
    |--------------------------------------------------------------------------
    |
    | This URL is used by the console to properly generate URLs when using
    | the Artisan command line tool. You should set this to the root of
    | your application so that it is used when running Artisan tasks.
    |
    */

    'url' => env('APP_URL', 'http://localhost'),

    /*
    |--------------------------------------------------------------------------
    | Application Timezone
    |--------------------------------------------------------------------------
    |
    | Here you may specify the default timezone for your application, which
    | will be used by the PHP date and date-time functions. We have gone
    | ahead and set this to a sensible default for you out of the box.
    |
    */

    'timezone' => 'UTC',

    /*
    |--------------------------------------------------------------------------
    | Application Locale Configuration
    |--------------------------------------------------------------------------
    |
    | The application locale determines the default locale that will be used
    | by the translation service provider. You are free to set this value
    | to any of the locales which will be supported by the application.
    |
    */

    'locale' => 'en',

    /*
    |--------------------------------------------------------------------------
    | Application Fallback Locale
    |--------------------------------------------------------------------------
    |
    | The fallback locale determines the locale to use when the current one
    | is not available. You may change the value to correspond to any of
    | the language folders that are provided through your application.
    |
    */

    'fallback_locale' => 'en',

    /*
    |--------------------------------------------------------------------------
    | Encryption Key
    |--------------------------------------------------------------------------
    |
    | This key is used by the Illuminate encrypter service and should be set
    | to a random, 32 character string, otherwise these encrypted strings
    | will not be safe. Please do this before deploying an application!
    |
    */

    'key' => env('APP_KEY'),

    'cipher' => 'AES-256-CBC',

    /*
    |--------------------------------------------------------------------------
    | Autoloaded Service Providers
    |--------------------------------------------------------------------------
    |
    | The service providers listed here will be automatically loaded on the
    | request to your application. Feel free to add your own services to
    | this array to grant expanded functionality to your applications.
    |
    */

    'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
        Illuminate\Auth\AuthServiceProvider::class,
        Illuminate\Broadcasting\BroadcastServiceProvider::class,
        Illuminate\Bus\BusServiceProvider::class,
        Illuminate\Cache\CacheServiceProvider::class,
        Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
        Illuminate\Cookie\CookieServiceProvider::class,
        Illuminate\Database\DatabaseServiceProvider::class,
        Illuminate\Encryption\EncryptionServiceProvider::class,
        Illuminate\Filesystem\FilesystemServiceProvider::class,
        Illuminate\Foundation\Providers\FoundationServiceProvider::class,
        Illuminate\Hashing\HashServiceProvider::class,
        Illuminate\Mail\MailServiceProvider::class,
        Illuminate\Notifications\NotificationServiceProvider::class,
        Illuminate\Pagination\PaginationServiceProvider::class,
        Illuminate\Pipeline\PipelineServiceProvider::class,
        Illuminate\Queue\QueueServiceProvider::class,
        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,

        /*
         * Package Service Providers...
         */
        Baum\Providers\BaumServiceProvider::class,
        Artesaos\SEOTools\Providers\SEOToolsServiceProvider::class,
        Barryvdh\DomPDF\ServiceProvider::class,

        /*
         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
        App\Providers\AuthServiceProvider::class,
        App\Providers\BroadcastServiceProvider::class,
        App\Providers\EventServiceProvider::class,
        App\Providers\TelescopeServiceProvider::class,
        App\Providers\RouteServiceProvider::class,
        App\Providers\CollectionServiceProvider::class,

        Laravel\Cashier\CashierServiceProvider::class,
        Spatie\Backup\BackupServiceProvider::class,
        willvincent\Rateable\RateableServiceProvider::class,
        Benwilkins\FCM\FcmNotificationServiceProvider::class,
    ],

    /*
    |--------------------------------------------------------------------------
    | Class Aliases
    |--------------------------------------------------------------------------
    |
    | This array of class aliases will be registered when this application
    | is started. However, feel free to register as many as you wish as
    | the aliases are "lazy" loaded so they don't hinder performance.
    |
    */

    'aliases' => [

        'App'          => Illuminate\Support\Facades\App::class,
        'Arr'          => Illuminate\Support\Arr::class,
        'Artisan'      => Illuminate\Support\Facades\Artisan::class,
        'Auth'         => Illuminate\Support\Facades\Auth::class,
        'Blade'        => Illuminate\Support\Facades\Blade::class,
        'Broadcast'    => Illuminate\Support\Facades\Broadcast::class,
        'Bus'          => Illuminate\Support\Facades\Bus::class,
        'Cache'        => Illuminate\Support\Facades\Cache::class,
        'Config'       => Illuminate\Support\Facades\Config::class,
        'Cookie'       => Illuminate\Support\Facades\Cookie::class,
        'Crypt'        => Illuminate\Support\Facades\Crypt::class,
        'DB'           => Illuminate\Support\Facades\DB::class,
        'Eloquent'     => Illuminate\Database\Eloquent\Model::class,
        'Event'        => Illuminate\Support\Facades\Event::class,
        'File'         => Illuminate\Support\Facades\File::class,
        'Gate'         => Illuminate\Support\Facades\Gate::class,
        'Hash'         => Illuminate\Support\Facades\Hash::class,
        'Lang'         => Illuminate\Support\Facades\Lang::class,
        'Log'          => Illuminate\Support\Facades\Log::class,
        'Mail'         => Illuminate\Support\Facades\Mail::class,
        'Notification' => Illuminate\Support\Facades\Notification::class,
        'Password'     => Illuminate\Support\Facades\Password::class,
        'Queue'        => Illuminate\Support\Facades\Queue::class,
        'Redirect'     => Illuminate\Support\Facades\Redirect::class,
        'Redis'        => Illuminate\Support\Facades\Redis::class,
        'Request'      => Illuminate\Support\Facades\Request::class,
        'Response'     => Illuminate\Support\Facades\Response::class,
        'Route'        => Illuminate\Support\Facades\Route::class,
        'Schema'       => Illuminate\Support\Facades\Schema::class,
        'Session'      => Illuminate\Support\Facades\Session::class,
        'Storage'      => Illuminate\Support\Facades\Storage::class,
        'Str'          => Illuminate\Support\Str::class,
        'URL'          => Illuminate\Support\Facades\URL::class,
        'Validator'    => Illuminate\Support\Facades\Validator::class,
        'View'         => Illuminate\Support\Facades\View::class,

        'Application' => \App\Services\Application::class,
        'Socialite'   => Laravel\Socialite\Facades\Socialite::class,
        'Goutte'      => Weidner\Goutte\GoutteFacade::class,
        'Excel'       => Maatwebsite\Excel\Facades\Excel::class,
        'ModelHelper' => \App\Services\ModelHelper::class,
        'SEOMeta'       => Artesaos\SEOTools\Facades\SEOMeta::class,
        'OpenGraph'     => Artesaos\SEOTools\Facades\OpenGraph::class,
        'Twitter'       => Artesaos\SEOTools\Facades\TwitterCard::class,
        'TwilioService' => Aloha\Twilio\Support\Laravel\Facade::class,
        'PDF' => Barryvdh\DomPDF\Facade::class,
        'Markdown' => GrahamCampbell\Markdown\Facades\Markdown::class,
    ],

];
lasselehtinen commented 5 years ago

I am having the same issue with an update from 5.7 to 5.8.

ghost commented 5 years ago

Hi; I started with fresh 5.8 Laravel installation. And received the mentioned exception. composer require laravel/slack-notification-channel fixed the problem in my case.

driesvints commented 5 years ago

I just tested this myself and this works fine. It seems there's something specific with your installs that's causing this not to work. @rjchauhan @lasselehtinen I really don't know what else can be done to figure out why it's not working for the both of you.

Please try to create an app and upload it to Github that recreates the problem so we can test it out. Let me know if you succeeded and I'll look into it.

josegus commented 5 years ago

Same here, i updated from 5.7 to 5.8, recently installed slack channel to log error and didn't work. I've changed the .env channel to slack, but nothing happend.

josegus commented 5 years ago

Nevermind, now is working, it was a problem with the level for each channel

alasdairw commented 5 years ago

Just noting - I'm having the same problem. Upgraded app, followed all the guides, same problem with Slack driver. If @lasselehtinen or @rjchauhan has had the "oh, that's what I did wrong" moment, I'd be really grateful if they could point me in the right direction!

alasdairw commented 5 years ago

In case anyone else turns up here from googling the same error:

php artisan config:clear php artisan cache:clear php artisan package:discover

fixed it for me.

rjchauhan commented 5 years ago

I figured out what the issue is. This package is getting discovered by auto discovery, but somehow it's not loading before AppServiceProvider. If I put \Illuminate\Notifications\SlackChannelServiceProvider::class (in app.php config file) before AppServiceProvider::class then it works fine, else not!

driesvints commented 5 years ago

@rjchauhan I don't have to do that and it works just fine

driesvints commented 5 years ago

Are you all using v2? Because v1 isn't supported on Laravel 5.8

alasdairw commented 5 years ago

@driesvints Definitely using V2 here - composer.json: "laravel/slack-notification-channel": "^2.0" and files on disk matches the repo at that version.

alasdairw commented 5 years ago

Having just tested pulling the changes I made last night through onto a different dev VM - it's only actually manually running php artisan package:discover that is to be required to pick up the Slack driver.

Not really a surprise, just wanted to note that the config/cache parts of what I posted above were not actually required.

rjchauhan commented 5 years ago

Yes, @driesvints I'm using v2. And on fresh Laravel 5.8 installation everything works fine. This issue only comes up on application where I upgrade from 5.7 to 5.8 😄

It's fixed by registering SlackChannelServiceProvider above AppServiceProvider and receiving notifications on slack as well.

driesvints commented 5 years ago

@rjchauhan you really don't need to do that so the problem is somewhere else

rjchauhan commented 5 years ago

Yes, I thought the same. Seems like it should be a problem somewhere in package auto discovery. or somehow slack channel service provider is not getting registered before application boots up.

theriddleofenigma commented 5 years ago

@driesvints I too have the same issue while upgrading the laravel framework version 5.7 to 5.8.

theriddleofenigma commented 5 years ago

I have installed v1.0.3. It works fine for me.

pedmindset commented 4 years ago

Having the same issue with laravel 6.4, i upgraded from laravel 5.8 sometime ago. I have tried everything here still not working.

driesvints commented 4 years ago

I'm currently using the slack driver perfectly in a live app. Please all, try a support channel:

Thanks.