gnello / php-mattermost-driver

The PHP Driver to interact with the Mattermost Web Service API.
Apache License 2.0
79 stars 26 forks source link

Fatal error: Declaration of Illuminate #44

Open Boffice opened 2 years ago

Boffice commented 2 years ago

Fatal error: Declaration of Illuminate\Container\Container::has($id) must be compatible with Psr\Container\ContainerInterface::has(string $id): bool in /vendor/illuminate/container/Container.php on line 169

php 7.4

"gnello/php-mattermost-driver": "^2.15"

gnello commented 2 years ago

Hi @Boffice, could you provide a code sample to reproduce the problem? I was not able to replicate the issue.

Thanks.

Boffice commented 2 years ago
private static function getDriver()
{
    static $driverInstance = null;

    if ($driverInstance !== null) {
        return $driverInstance;
    }

    $container = new \Pimple\Container([
        'driver' => [
            'url' => '*',
            'login_id' => '*',
            'password' => '*',
        ]
    ]);

    $driverInstance = new Driver($container);
    $driverInstance->authenticate();
    return $driverInstance;
}

public function add_user()
{
    $driver = $this->getDriver();

    //Add a new user
    $result = $driver->getUserModel()->createUser([
        'email'    => 'test@test.com', 
        'username' => 'test', 
        'password' => 'testpsw'
    ]);

    echo $this->print($result);
}
gnello commented 2 years ago

Hi @Boffice, I can not replicate your problem, it seems ok to me. Plus, I did not figure out how is possible to have that kind of error since this library do not use any Laravel package.

I may suggest you to verify where you are using the Illuminate\Container\Container, and try to follow the error stack trace to get to the source of the problem. Let me know if you need any help with this.

If you are using this library whithin Laravel, maybe you can find more suitable the Laravel Mattermost Driver.

Boffice commented 2 years ago

Looks like psr/container conflicts with Illuminate/container, and i am using Codeigniter. Illuminate/Container is needed for other modules and can't be removed.

gnello commented 2 years ago

That is ok, but how is this related to the php-mattermost-driver? The code you posted can not generate that kind of error.

Boffice commented 2 years ago

Issue appears once i include require('modules/mattermost/vendor/autoload.php'); to the controller. driver loads psr/container which conflicts with illuminate/container.

even

public function index()
{
  echo 'hello world';
}

Returns same error.

gnello commented 2 years ago

Hi @Boffice, sorry for the late response.

Any update on this?

Boffice commented 2 years ago

Hello, was not able to get around this issue.