slack-laravel
slack-laravel copied to clipboard
Remove share method
This PR fixed the following error I got after updating to 5.4
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
PHP Fatal error: Call to undefined method Illuminate\Foundation\Application::share() in /Users/.../vendor/maknz/slack-laravel/src/ServiceProviderLaravel5.php on line 29
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined method Illuminate\Foundation\Application::share()
That solves the undefined method but I found it didn't actually work with just that change, this is what I did to get it working:
Note the bind
is now a class reference rather than a string, as detailed in the upgrade guide. https://laravel.com/docs/5.4/upgrade (Search for Binding Classes With Leading Slashes
) and you don't need to assign $this->app->singleton
to anything.
public function register()
{
$this->mergeConfigFrom(__DIR__.'/config/config.php', 'slack');
$this->app->singleton('maknz.slack', function ($app) {
return new Client(
$app['config']->get('slack.endpoint'),
[
'channel' => $app['config']->get('slack.channel'),
'username' => $app['config']->get('slack.username'),
'icon' => $app['config']->get('slack.icon'),
'link_names' => $app['config']->get('slack.link_names'),
'unfurl_links' => $app['config']->get('slack.unfurl_links'),
'unfurl_media' => $app['config']->get('slack.unfurl_media'),
'allow_markdown' => $app['config']->get('slack.allow_markdown'),
'markdown_in_attachments' => $app['config']->get('slack.markdown_in_attachments'),
],
new Guzzle
);
});
$this->app->bind(Maknz\Slack\Client::class, 'maknz.slack');
}
@connorjburton This is the right approach.
@connorjburton Willing to make pull request? @maknz Willing to merge?
See #11
I think this repo is dead and should be transferred to organization or person who will maintain it. @maknz
I just made a fork and fixed it there: if anybody is interested: https://github.com/phpify/slack-laravel or just composer require phpify/slack-laravel