I had the same problem as you, but I managed to log into my application. I followed Robβs advice and created my own factory service in my existing user module. Unfortunately, Bernhard is also in place. You need to delve into the source code of ZfcUser to make it work. The project I'm working on now has an MSSQL server, and I have to say that it was difficult to get information about things. I finished setting up only one function in the ZfcUser source to make the login page work.
I only need the login function for the current application, but the upcoming project is much more role-oriented. I was looking for something that would not be too complicated to quickly connect and at the same time offer more opportunities and opportunities for the future.
Here is what I have done now and what I have learned:
I copied the Entity and Mapper folders from the ZfcUser directory to my existing b2bUser folder (my module). Everything ... even the Exclusions folder inside Mapper. Perhaps this is not necessary, but I was not in the mood to figure out the dependencies.
In the zfcuser.global.php file, my active configuration is as follows:
'user_entity_class' => 'b2bUser\Entity\User', 'enable_registration' => false, 'enable_username' => true, 'auth_identity_fields' => array( 'username' ), 'login_redirect_route' => 'home', 'enable_user_state' => false,
I left the rest of the default settings. I removed the email option from authentication credentials because they will not use email addresses to log in. user_entity_class is the one I copied ...
Module.php (b2bUser) The following is copied to the service manager configuration:
'zfcuser_user_mapper' => function ($sm) { $mapper = new Mapper\User(); $mapper->setDbAdapter($sm->get('Zend\Db\Adapter\Adapter')); $mapper->setEntityPrototype(new Entity\User()); $mapper->setHydrator(new Mapper\UserHydrator()); return $mapper; },
After completing the setup, I changed namespaces, etc. files in Entity and Mapper to reflect their new home. Entity and interface changed to reflect my own data structure. I did the same with the Mapper files and made sure that the variable names in the Hydrator file match the database column names.
I left the AbstractDbMapper file where it was. But this is a file that I changed a little.
This is what mine looks like. The SQLSRV driver was full of fluff, all the while complaining about an object or string ...
protected function select(Select $select, $entityPrototype = null, HydratorInterface $hydrator = null) { $this->initialize(); $selectString = $this->getSlaveSql()->getSqlStringForSqlObject($select); $stmt = $this->getDbAdapter()->driver->createStatement($selectString); $stmt->prepare(); $res = $stmt->execute($stmt); $resultSet = new HydratingResultSet($hydrator ?: $this->getHydrator(), $entityPrototype ?: $this->getEntityPrototype()); $resultSet->initialize($res); return $resultSet; }
And it's all. Hope this helps someone up and work on their own system, at least. I will not leave mine like this, but it was a small mission to make it work.