cartalyst / sentinel

A framework agnostic authentication & authorization system.
BSD 3-Clause "New" or "Revised" License
1.51k stars 238 forks source link

Conflict with Illuminate/events 5.8 #455

Closed a3gz closed 5 years ago

a3gz commented 5 years ago

Hello

I'm getting an error when I try to registerAndActivate() a user. The error is:

Call to undefined method Illuminate\Events\Dispatcher::fire()

thrown at

cartalyst/support/src/Traits/EventTrait.php

on line 127.

I learned that Illuminate Events removed the fire() event on version 5.8. I think that the problem is that Sentinel requires illuminate/support ~5.0 which I believe accepts any version less than 6.0 thus, 5.8.

I think this could be solved in at least two ways:

One could be to change the dependency on Illuminate support to up to illuminate/support 5.7.

The other one could be to change EventTrait (which is technically external to cartalyst/sentinel) on line 125 from:

$method = $halt ? 'until' : 'fire';

to

$method = $halt ? 'until' : 'dispatch';

I wasn't sure where to post this issue because cartalyst/support, to which EventTrait.php belongs doesn't required illuminate/support; it's actually cartalyst/sentinel that requires it. So, although the code that throws the error is not inside this project's code, it is this project's dependency that exposes the conflict. So I'm not really sure if I should have posted this issue on cartalyst/support instead.

atxy2k commented 5 years ago

I have the same issue

Mxrck commented 5 years ago

I have this problem too, i made a pull request in cartalyst/support, meanwhile i create a package with the fix, waiting by their own fix

https://github.com/Mxrck/sentinel

composer require mxrck/sentinel:2.0.18

Mxrck commented 5 years ago

found also calls to str helpers in a few files on this package

https://github.com/Mxrck/sentinel/commit/127d836c0a050084c50eea246d6d08446a72e75c

I don't know how to made pull request without the composer.json updated in my fork

drsii commented 5 years ago

An FYI, we will have this repo updated by monday. @Mxrck appreciate your good work.

ninja1ndia commented 5 years ago

@a3gz save entry with activated = true

a3gz commented 5 years ago

@Surya1995 I'm not entirely sure that I understand what you mean, but if I do then: the fireEvent() method will be called anyway from register().

RalphMRivera commented 5 years ago

As an FYI, here's the error output I get when running tests:

Error: Call to undefined method Illuminate\Support\Testing\Fakes\EventFake::fire()

/home/vagrant/ptbx-franklin/vendor/cartalyst/support/src/Traits/EventTrait.php:127
/home/vagrant/ptbx-franklin/vendor/cartalyst/sentinel/src/Sentinel.php:169
/home/vagrant/ptbx-franklin/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:237

Implementing the solution provided by @a3gz fixed the problem for me and all my tests ran successfully.

brunogaspar commented 5 years ago

Released cartalyst/support v2.0.2 and then v2.0.3 with a small revision.

Give composer update a go and see if it solves the issue and works as expected.

brunogaspar commented 5 years ago

@Mxrck Feel free to submit a pull request with your other changes for dropping the usage of the deprecated Laravel helpers and use the classes instead.

RalphMRivera commented 5 years ago

@brunogaspar I just deleted my Vendor folder, ran composer install and everything ran great. Thanks for all your hard work!

a3gz commented 5 years ago

@brunogaspar Problem solved; Thank you very much!