Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8984929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:13:26+00:00 2026-06-15T21:13:26+00:00

I`ve added module ZfcUser on my Zend Framework 2 application. But I have to

  • 0

I`ve added module ZfcUser on my Zend Framework 2 application.
But I have to use existing database table,
which has slightly different column names than the default table structure for ZfcUser.

In ZfcUser wiki page it says that it is possible to use custom mapper if my model doesn`t conform to the provided interface.
And since my database table is different than default, my user entity class is also different than
standard ZfcUser\Entity\User. But I can tell ZfcUser to work with my own class easily
by overriding setting in file config/autoload/zfcuser.global.php:

'user_entity_class' => 'MyApp\Entity\MyUser',

But I`ve not found an easy way to tell ZfcUser to use my mapper class so far.

I have only found that the mapper is created by ZfcUser\Module::getServiceConfig()
inside which, I can see the mapper is returned from its factory function:

// ...
public function getServiceConfig()
{
    return array(
    // ...
        'factories' => array(
            // ...
            'zfcuser_user_mapper' => function ($sm) {
                $options = $sm->get('zfcuser_module_options');
                $mapper = new Mapper\User();
                $mapper->setDbAdapter($sm->get('zfcuser_zend_db_adapter'));
                $entityClass = $options->getUserEntityClass();
                $mapper->setEntityPrototype(new $entityClass);
                $mapper->setHydrator(new Mapper\UserHydrator());
                return $mapper;
            },
            // ...

Is there a way to make ZfcUser to use my custom user mapper class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:13:27+00:00Added an answer on June 15, 2026 at 9:13 pm

    I’ve had the same problem as you, but managed to log in to my application at last. I followed Rob’s advice and created my own service factory within my existing user module. Unfortunately Bernhard is also spot on. You kinda have to dig into the ZfcUser source code to get it to work. The project I am working on now has a MSSQL server and I must say that it’s been tough getting a handle on things. I’ve ended up tweaking only one function in the ZfcUser source to get the login page to work.

    I only need log in functionality for the current application, but the upcoming project is much more role driven. I was looking for something that wouldn’t be too complicated to hook up quickly, and at the same time offer more options and possibilities for the future.

    Here is what I did for now and what I’ve learned:

    I copied the Entity and Mapper folders from the ZfcUser directory over to my existing b2bUser (my module) folder. Everything…even the Exception folder inside Mapper. It might not be necessary, but I wasn’t in the mood to figure out dependencies.

    In the zfcuser.global.php file, my active configuration looks 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 settings on default. I removed the email option from auth identities because they won’t use email addresses to log into the system. The user_entity_class is the one I copied over…

    Module.php (b2bUser)
    Copied the following to the service manager config:

    '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 the setup was done, I changed the namespaces, etc of the files in Entity and Mapper to reflect their new home. Changed the Entity and the Interface to reflect my own data structure. I did the same with the Mapper files and made sure the variable names in the Hydrator file is the same as my database column names.

    I left the AbstractDbMapper file where it was. But this is the file I tweaked a bit.

    Here is what mine looks like. The SQLSRV driver was full of pooh, complaining the whole time about an object or a 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 that is that. I hope it helps someone to get it up and running on their own system at least. I won’t leave mine like this, but it was a bit of a mission to get it to work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Play application, I've added Secure module. But I haven't found a way
I have a guice module added to the injector using injector = Guice.createInjector(... but
I have one asp.net mvc 3 application (www.name.com) with custom module added to web.config:
I have to build a custom module in which i have added a custom
I added a configuration variable in application.rb such as module Www class Application <
In one of my iOS project I have add a sub-module added, lets say
I'm developing an newsletter sending application on C#/.NET platform. I've recently added the module
Given below is my Model definition and I have added this module part of
I have added a module to show the some set of images with text
I have one testing module that I want to use for android testing. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.