ZF-Commons / ZfcUser

A generic user registration and authentication module for ZF2. Supports Zend\Db and Doctrine2. (Formerly EdpUser)
BSD 3-Clause "New" or "Revised" License
497 stars 343 forks source link

ZF3 Compatibility #642

Closed Rockstar04 closed 7 years ago

Rockstar04 commented 8 years ago

ZF3 has officially been released: https://framework.zend.com/blog/2016-06-28-zend-framework-3.html

oprokidnev commented 8 years ago

+1

pdrosos commented 8 years ago

+1

telkins commented 8 years ago

+1

Rockstar04 commented 8 years ago

Actually it looks like 1.4.4 has been updated for the new ServiceManger already. It was issues with how my code was overriding ZfcUser classes that caused an issue I assumed was ZF3 incompatibility.

telkins commented 8 years ago

@Rockstar04 I could be wrong, but I don't think it's that simple. ZfcUser requires ZfcBase which in turn requires zend-mvc ~2.1. If one tries to use ZfcUser with zend-mvc 3, then there's a conflict.

Now...there may be a way around this that I don't know about. If so, please enlighten me. Otherwise, if my understanding is correct, then ZfcBase's dependencies need to be updated or, better yet, ZfcBase should be dropped as a dependency for ZfcUser....which is the goal of #560.

If I'm right, please re-open. If not, please help me to use zend-mvc 3 correctly. I'd appreciate it. :-)

Rockstar04 commented 8 years ago

@telkins You are right, I was looking over quite a few of my projects dependencies yesterday and forgot about the tie to zend-mvc, I was just looking over the version history here and got ahead of myself.

telkins commented 8 years ago

@Rockstar04 👍 Nice...! The dependencies can be a bit tricky, sometimes. I'm hoping that #560 can be resolved quickly since there doesn't appear to be any need for it any longer. Once that's done, I think the task becomes relatively straightforward. Let's hope so, anyway. :-)

stijnhau commented 8 years ago

I'm doing some changes on the dev-master to add support for ZF3. Also because there are chaanges in the factoryInterface and so on ;)

Danielss89 commented 8 years ago

@stijnhau Can you do it in 1.x, without BC breaks?

stijnhau commented 8 years ago

@Danielss89 I will first do the dev-master because that is the one i'm using ;) and i don't have that much time. Did already a small change and should have no BC break(Not yet commited)

telkins commented 8 years ago

@stijnhau Any ETA...?

stijnhau commented 8 years ago

@telkins I hope to finish dev-master this weekend

stijnhau commented 8 years ago

https://github.com/stijnhau/ZfcUser/tree/ZF3

For people who wants to help also ;) Or people that are intrested to see the changes. Have updated the composer.json file Dropped zfcBase dependency(only dropped nothing changed yet will see where it's used and do changes then). Working on factories now. This way i'm working they also should be compatible with ZF2 and ZF3

svycka commented 8 years ago

@stijnhau create a PR from that

stijnhau commented 8 years ago

@svycka The moment i'm ready i will Todo:

svycka commented 8 years ago

you can do changes on PR so why ou cant create it now and do your changes later? it would be easier to see what you changed and comment what you did wrong, suggest what to fix and so on

stijnhau commented 8 years ago

@svycka I'm more a fan of creating the PR when it's ready so that way ou cna see the working result cause now it to uch a work in progress.

oprokidnev commented 8 years ago

@stijnhau I think that saving both SMv2 and SMv3 compaibility is not a good idea.

stijnhau commented 8 years ago

@oprokidnev Why do u think it's a bad idea?

telkins commented 8 years ago

My 2 cents: I think both SMv2 and SMv3 should be supported. Otherwise, there need to be separate versions of ZfcUser.

While I would prefer to move ahead and stay at the cutting edge, having only support for the latest and greatest, there are some situations where it's not possible/realistic. The ZF developers have provided a way to support both versions simultaneously for a reason. It's because not everyone will be willing/able to move forward.

Also, keep in mind that a single dependency can potentially be a single factor in forcing one forward or keeping one back. I've gone through the work of upgrading to SMv3 and found that a single dependency, like ZfcUser, will hold me back. Of course, if ZfcUser now suddenly supports only SMv3, then those who are not ready to move ahead will be forced to...or they will miss out on further ZfcUser fixes/features.

So, supporting both is a good step forward...at least if there's only going to be one version. If it's a matter of how to move ahead with 1.x, then support for both is the only realistic/pragmatic solution. If it's a matter of having a ZfcUser solution that only supports SMv3, then I think that means an introduction of a 2.x version is necessary, since it will no longer be backward compatible.

My vote for now: bridge the gap and support both. It's a relatively simple fix and any disadvantages (that I can think of) are negligible.

stijnhau commented 8 years ago

Yes telkins that is the reason i wan't to have SMv2 and SMv3 support.

stijnhau commented 8 years ago

Havin major issue at the moment with refactoring. Event's is still undecided how i'm going to handle those so put in comment for now. https://github.com/zendframework/zend-mvc-plugin-flashmessenger Check that repo it is the slashmessanger but it support onnly zend-mvc 3.x branch. Any idea how we can work around that?

adamlundrigan commented 8 years ago

@stijnhau you could probably add a Composer script that checks the installed version of zend-mvc and if it is ^3.0 then also install the necessary zend-mvc-plugin-* repositories.

My 2 cents though would be to explictly declare ZfcUser 1.x as being for ZF2 and do a ZfcUser 2.x release for ZF3. Last time I was actively using ZfcUser I advocated for v2.x to be split, putting MVC integration into a separate package and so allowing easier reuse of the ZfcUser "core" in other contexts (eg: Apigility). That would also help in this case: MVC 2.x and MVC 3.x support could be provided through separate packages, if necessary.

adamlundrigan commented 8 years ago

After more thought, In the interim I suggest this: we release a ZfcUser v2.x that supports only zend-mvc 3.x but is otherwise identical to ZfcUser 1.x, then relabel the current master branch as ZfcUser 3.x (since it already has BC-breaking changes committed, IIRC). It does, however, mean we are now concurrently maintaining 3 branches, so maybe lock <3.0 to only backporting of critical bug fixes?

(that "we" seems to be just Daniel now, tbh, so of course it would be up to him if he wants to expend that maintenance effort)

stijnhau commented 8 years ago

Okez you are right a change i did earlier already requires MVCv3 and php 5.6 so i've updated the composer fiole to request the new changes. Will see that i can look for the event tomorrow and can do a testrun and update the readme

Danielss89 commented 8 years ago

I will do a reply tomorrow evening on what i decide with branches and BC.

oprokidnev commented 8 years ago

@stijnhau You've just mention why (zend-mvc-* repos). The second point is that this module requires massive refactoring:

Saving BC would make module development harder. Module is stable enought for now and new version of module should only be compatible with latest dev options

stijnhau commented 8 years ago

@oprokidnev Wat is wrong with the service config like it is used in the dev master at the moment?

An update on the state of the change: Having issues at the moment withthe autenticate function that gives a fatal somewhere(do not have the code or testexample next to me)

Danielss89 commented 8 years ago

I decided to go the following way: ZfcUser 1.x = Supports ZF2.0 - Only receives security updates ZfcUser 2.x = Copy of current 1.x, but with refactors(and BC breaks) to support servicemanager 3 ZfcIser master = Future version, with many changes and BC breaks.

I have vacation next week, and will update Github accordingly. Feel free to create PR's :)

stijnhau commented 8 years ago

I propse 1 change extra for zfcuser 2.0 Thé user_id to id

Danielss89 commented 8 years ago

@stijnhau No, that is too big a BC. I want BC breaks to be as few and small as possible.

stijnhau commented 8 years ago

Agreed but it will be a new major version. So I don't see a reason to keep that faulty dB design

Danielss89 commented 8 years ago

If you have an existing app and want's to upgrade to ZF3, you want as minimal changes as possible. Changing user_id to id will require you to change a lot of your entities with an association to the user entity, and you will have to change your database also, which can be a bit difficult.

The "new" version of ZfcUser, is not meant for upgrading, but for new project, so there it is fine to do the change.

oprokidnev commented 8 years ago

@Danielss89 You can try my fork as a base. Has reached some forms to be working, but currently has no time for this. BC breaks with zf2. https://github.com/oprokidnev/ZfcUser/tree/zf3 https://github.com/oprokidnev/ZfcBase/tree/zf3

Danielss89 commented 8 years ago

Hi All

I've finally had some more time to work on this(it required more work than i first thought). Anyway, i pushed a 2.x branch, i haven't tagged yet, as i would like your feedback and testing for this.

stijnhau commented 8 years ago

@Danielss89 Can you take a look at my fork of the master for V3 support? Cause i'm stuck somewhere TypeError File: C:\Program Files (x86)\Zend\ZendServer\data\apps\httpdefault\0\Zf2TestProject\1.0.0_12\vendor\zf-commons\zfc-user\src\ZfcUser\Authentication\Adapter\Db.php:52 Message: Argument 1 passed to ZfcUser\Authentication\Adapter\Db::authenticate() must be an instance of ZfcUser\Authentication\Adapter\AdapterChainEvent, instance of Zend\EventManager\Event given, called in C:\Program Files (x86)\Zend\ZendServer\data\apps\httpdefault\0\Zf2TestProject\1.0.0_12\vendor\zendframework\zend-eventmanager\src\EventManager.php on line 271 Stack trace:

0 C:\Program Files (x86)\Zend\ZendServer\data\apps\httpdefault\0\Zf2TestProject\1.0.0_12\vendor\zendframework\zend-eventmanager\src\EventManager.php(271): ZfcUser\Authentication\Adapter\Db->authenticate(Object(Zend\EventManager\Event))

1 C:\Program Files (x86)\Zend\ZendServer\data\apps\httpdefault\0\Zf2TestProject\1.0.0_12\vendor\zendframework\zend-eventmanager\src\EventManager.php(122): Zend\EventManager\EventManager->triggerListeners(Object(Zend\EventManager\Event))

2 C:\Program Files (x86)\Zend\ZendServer\data\apps\httpdefault\0\Zf2TestProject\1.0.0_12\vendor\zf-commons\zfc-user\src\ZfcUser\Authentication\Adapter\AdapterChain.php(58): Zend\EventManager\EventManager->trigger('authenticate', Object(ZfcUser\Authentication\Adapter\AdapterChainEvent), Object(Closure))

3 C:\Program Files (x86)\Zend\ZendServer\data\apps\httpdefault\0\Zf2TestProject\1.0.0_12\vendor\zf-commons\zfc-user\src\ZfcUser\Controller\UserController.php(164): ZfcUser\Authentication\Adapter\AdapterChain->prepareForAuthentication(Object(Zend\Http\PhpEnvironment\Request))

4 C:\Program Files (x86)\Zend\ZendServer\data\apps\httpdefault\0\Zf2TestProject\1.0.0_12\vendor\zendframework\zend-mvc\src\Controller\AbstractActionController.php(78): ZfcUser\Controller\UserController->authenticateAction()

5 C:\Program Files (x86)\Zend\ZendServer\data\apps\httpdefault\0\Zf2TestProject\1.0.0_12\vendor\zendframework\zend-eventmanager\src\EventManager.php(271): Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))

6 C:\Program Files (x86)\Zend\ZendServer\data\apps\httpdefault\0\Zf2TestProject\1.0.0_12\vendor\zendframework\zend-eventmanager\src\EventManager.php(151): Zend\EventManager\EventManager->triggerListeners(Object(Zend\Mvc\MvcEvent), Object(Closure))

7 C:\Program Files (x86)\Zend\ZendServer\data\apps\httpdefault\0\Zf2TestProject\1.0.0_12\vendor\zendframework\zend-mvc\src\Controller\AbstractController.php(105): Zend\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Zend\Mvc\MvcEvent))

8 C:\Program Files (x86)\Zend\ZendServer\data\apps\httpdefault\0\Zf2TestProject\1.0.0_12\vendor\zendframework\zend-mvc\src\Controller\Plugin\Forward.php(143): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))

9 C:\Program Files (x86)\Zend\ZendServer\data\apps\httpdefault\0\Zf2TestProject\1.0.0_12\vendor\zf-commons\zfc-user\src\ZfcUser\Controller\UserController.php(131): Zend\Mvc\Controller\Plugin\Forward->dispatch('zfcuser', Array)

10 C:\Program Files (x86)\Zend\ZendServer\data\apps\httpdefault\0\Zf2TestProject\1.0.0_12\vendor\zendframework\zend-mvc\src\Controller\AbstractActionController.php(78): ZfcUser\Controller\UserController->loginAction()

11 C:\Program Files (x86)\Zend\ZendServer\data\apps\httpdefault\0\Zf2TestProject\1.0.0_12\vendor\zendframework\zend-eventmanager\src\EventManager.php(271): Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))

12 C:\Program Files (x86)\Zend\ZendServer\data\apps\httpdefault\0\Zf2TestProject\1.0.0_12\vendor\zendframework\zend-eventmanager\src\EventManager.php(151): Zend\EventManager\EventManager->triggerListeners(Object(Zend\Mvc\MvcEvent), Object(Closure))

13 C:\Program Files (x86)\Zend\ZendServer\data\apps\httpdefault\0\Zf2TestProject\1.0.0_12\vendor\zendframework\zend-mvc\src\Controller\AbstractController.php(105): Zend\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Zend\Mvc\MvcEvent))

14 C:\Program Files (x86)\Zend\ZendServer\data\apps\httpdefault\0\Zf2TestProject\1.0.0_12\vendor\zendframework\zend-mvc\src\DispatchListener.php(119): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))

15 C:\Program Files (x86)\Zend\ZendServer\data\apps\httpdefault\0\Zf2TestProject\1.0.0_12\vendor\zendframework\zend-eventmanager\src\EventManager.php(271): Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))

16 C:\Program Files (x86)\Zend\ZendServer\data\apps\httpdefault\0\Zf2TestProject\1.0.0_12\vendor\zendframework\zend-eventmanager\src\EventManager.php(151): Zend\EventManager\EventManager->triggerListeners(Object(Zend\Mvc\MvcEvent), Object(Closure))

17 C:\Program Files (x86)\Zend\ZendServer\data\apps\httpdefault\0\Zf2TestProject\1.0.0_12\vendor\zendframework\zend-mvc\src\Application.php(332): Zend\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Zend\Mvc\MvcEvent))

18 C:\Program Files (x86)\Zend\ZendServer\data\apps\httpdefault\0\Zf2TestProject\1.0.0_12\public\index.php(40): Zend\Mvc\Application->run()

19 {main}

And if you look at the stacktrace the correct event is passes to the listener but when the listener is triggered it somehow back the wrong one.

adamlundrigan commented 8 years ago

@Danielss89 here's my feedback:

I haven't updated any of my projects to use ZF3 components yet (:disappointed:) so I can't actually test these changes beyond code review and running the tests.

stijnhau commented 8 years ago

I have doine some work for the dev master branch. Its currently works with ZF3 but there is still some cleanup needed and the user mapper has some todo's as weel. But it is already using tablegateway and not the db mapper like before.

olexp commented 8 years ago

@Danielss89 @adamlundrigan

There is an issue with extending forms via event (https://github.com/ZF-Commons/ZfcUser/wiki/How-to-modify-the-form-objects-used-by-ZfcUser) in 2.x-dev. Attaching listeners to authenticate.fail of ZfcUser\Authentication\Adapter\AdapterChain and init of ZfcUser\Form\Login failed for me. ProvidesEventsForm does not inject shared manager at all. EventProvider injects new instance of SharedEventManager that is different from one that could be get via application events in Module::onBootstrap().

RobertTutaev commented 7 years ago

When you're ready Zfcuser version 2? I can not migrate to zf3!

boscho87 commented 7 years ago

Go ! +1 !!

phgeek commented 7 years ago

Any news about ZF3 support?

savez commented 7 years ago

no i'm sorry

Danielss89 commented 7 years ago

There are still some problems with the PR, so i can't merge yet. Unfortunately i'm extremely busy right now, so i don't have the time to fix at this moment. Please feel free to create PR's agains mine, and help fix the bugs.

stijnhau commented 7 years ago

@Danielss89 Can you say wat your issues are at the moment?

Danielss89 commented 7 years ago

@stijnhau Well, i know there are some problems with the event stuff, but if you read the backlog of this issue, then it explains it better.

Sohorev commented 7 years ago

Please help, I am install stijnhau/ZfcUser from git hub and when I try to install zf-commons/zfc-user-doctrine-orm from composer I have an error:

composer require zf-commons/zfc-user-doctrine-orm
Using version ^1.0 for zf-commons/zfc-user-doctrine-orm
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - zf-commons/zfc-user-doctrine-orm 1.0.1 requires doctrine/doctrine-orm-module 0.* -> satisfiable by doctrine/doctrine-orm-module[0.1.0, 0.10.0, 0.11.0, 0.2.0, 0.2.1, 0.3.0, 0.3.1, 0.4.0, 0.5.0, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.5.5, 0.5.6, 0.5.7, 0.6.0, 0.7.0, 0.8.0, 0.8.0-beta1, 0.8.0-beta2, 0.8.0-beta3, 0.8.0-beta4, 0.9.0, 0.9.1, 0.9.2] but these conflict with your requirements or minimum-stability.
    - zf-commons/zfc-user-doctrine-orm 1.0.0 requires doctrine/doctrine-orm-module 0.* -> satisfiable by doctrine/doctrine-orm-module[0.1.0, 0.10.0, 0.11.0, 0.2.0, 0.2.1, 0.3.0, 0.3.1, 0.4.0, 0.5.0, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.5.5, 0.5.6, 0.5.7, 0.6.0, 0.7.0, 0.8.0, 0.8.0-beta1, 0.8.0-beta2, 0.8.0-beta3, 0.8.0-beta4, 0.9.0, 0.9.1, 0.9.2] but these conflict with your requirements or minimum-stability.
    - Installation request for zf-commons/zfc-user-doctrine-orm ^1.0 -> satisfiable by zf-commons/zfc-user-doctrine-orm[1.0.0, 1.0.1].

What me do?

CallumBrankin commented 7 years ago

any update on this? my module depends on this to allow my module to upgrade to zend framework 3

RobertTutaev commented 7 years ago

silent

jpalmer4444 commented 7 years ago

Me too - my module depends on this, any update?