Zend Framework 2: How to properly replace Figlet with reCaptcha on zfcUser -


i trying replace figlet recaptcha on zfcuser registration form. partial instruction on how accomplish can found on https://github.com/zf-commons/zfcuser#changing-registration-captcha-element no complete instruction exists.

checking readme.md file has two-step instruction on how accomplish still captcha uses figlet when rendered on form.

has implemented this? need hand on one.

thanks in advance.


edit: here proven working solution developed:

1. add composer.json

// add lines below under "require" element:     "require": {         "php": ">=5.3.3",         "zendframework/zendframework": ">2.2.0rc1",         "zendframework/zendservice-recaptcha": "2.*" 

}

2. goto project's zf2 installation directory , execute command:

php composer.phar update 

3. replace or create config/autoload/database.global.php with:

<?php $config = array(     'dbdriver' => 'pdo',     'dbhost' => 'localhost',     'dbport' => '3306',     'dbname' => 'changeme',     'dbuser' => 'changeme',     'dbpass' => 'changeme', );  return array(     'service_manager' => array(         'factories' => array(             'zend\db\adapter\adapter' => 'zend\db\adapter\adapterservicefactory',         ),     ),     'db' => array(         'driver'    => 'pdo',         'dsn'       => 'mysql:dbname='.$config['dbname'].';host='.$config['dbhost'],         'username'  => $config['dbuser'],         'password'  => $config['dbpass'],     ), ); 

4: execute on mysql server:

create table `user` (     `user_id` int unsigned not null auto_increment primary key,     `username` varchar(255) default null unique,     `email` varchar(255) default null unique,     `display_name` varchar(50) default null,     `password` varchar(128) not null,     `state` smallint unsigned ) engine=innodb charset="utf8"; 

5. create/replace config/autoload/recaptcha.global.php with:

<?php define('recaptcha_private_key','changeme'); define('recaptcha_public_key','changeme');  return array(     'zfcuser' => array(         'form_captcha_options' => array(             'class'   => 'zend\captcha\recaptcha',             'options' => array(                 'privkey' => recaptcha_private_key,                 'pubkey'  => recaptcha_public_key,             ),         ),     ),      'di'=> array(         'instance'=>array(             'alias'=>array(                 'recaptcha_element' => 'zend\form\element\captcha',             ),              'zfcuser\form\register' => array(                 'parameters' => array(                     'captcha_element'=>'recaptcha_element',                 ),             ),         ),     ), ); 

6. create/replace config/autoload/zfcuser.global.php with:

<?php $settings = array(         'enable_registration' => true,     'enable_username' => true,     'auth_adapters' => array( 100 => 'zfcuser\authentication\adapter\db' ),     'enable_display_name' => false,     'auth_identity_fields' => array( 'email' ),     'use_registration_form_captcha' => true,     'user_login_widget_view_template' => 'zfc-user/user/login.phtml', );   return array(     'zfcuser' => $settings,     'service_manager' => array(         'aliases' => array(             'zfcuser_zend_db_adapter' => (isset($settings['zend_db_adapter'])) ? $settings['zend_db_adapter']: 'zend\db\adapter\adapter',         ),     ), ); 

7. navigate http://yourdomain.com/user

8. enjoy! :)

how did it, might not best or correct way worked me:

add recaptcha service composer.json file:

"require": {     "zendframework/zendservice-recaptcha": "2.*" } 

run composer service. need specify recaptcha config. created separate config file store recaptcha keys:

//zfcuser.local.php return array(     'zfcuser' => array(         'form_captcha_options' => array(             'options' => array(                 'privkey' => recaptcha_private_key,                    'pubkey'  => recaptcha_public_key,             ),         ),     ), );  

then zfcuser captcha config looks so, telling use recaptcha service:

//zfcuser.global.php 'form_captcha_options' => array(     'class'   => 'zend\captcha\recaptcha',     'options' => array(         'wordlen'    => 6,         'expiration' => 300,         'timeout'    => 300,      ), ), 

edit:

you don't need recaptcha.global.php. can call config file whatever aslong ends .global.php or .local.php. name things .local.php when don't want them in version control.

in case named file zfcuser.local.php because store recaptcha keys , didn't want them in version control.

all config files merged in 1 array when application started. basically, ignore zfcuser documentation. or maybe else can explain how working way.

the third block of code zfcuser.global.php.


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -