Filipe Ferminiano Filipe Ferminiano - 4 months ago 44
PHP Question

Call to undefined method from composer added package

I'm trying to use SlackBot class with my Laravel 5 app.

But I'm getting this error:

Call to undefined method Mpociot\SlackBot\Facades\SlackBot::initialize()

This is my controller:

use SlackBot;

public function slack_bot()

$slackbot = new SlackBot();


I tried to debug which methods are available with this:

$methods = get_class_methods($slackbot);

and I got this:

Array ( [0] => swap [1] => shouldReceive [2] => getFacadeRoot [3] => clearResolvedInstance [4] => clearResolvedInstances [5] => getFacadeApplication [6] => setFacadeApplication [7] => __callStatic )

which is very different from the methods defined in github class]2.

How can I fix this?

What I have done:

I'm following this tutorial

I ran composer require mpociot/slackbot

And then I added to config/app.php the service provider:


and the alias / facade:

'SlackBot' => Mpociot\SlackBot\Facades\SlackBot::class


You're getting a instance of the Facade instead of the real class.

Replace your

    $slackbot = new SlackBot();


    $slackbot = SlackBot::initialize('token');