Zend Framework 2
Updated June 30th 2017Tested with Zend Framework 2 Version: 2.5.3
- Step-by-step installation guide
- Testing the module
Step-by-step installation guide
This tutorial is based off the Zend Framework 2.x MVC Skeleton Application.
PixelPin Auth is a Zend Framework 2 Module for authenticating with PixelPin using the Oauth2 API.
PixelPin Auth allows you to connect your website to PixelPin and let users authenticate using passwordless pictures. With PixelPin Auth module your users can log in to your website using their PixelPin pictures. With PixelPin Auth, users will no longer need to complete numerous forms for a successful registration.
To complete the installation, you'll need to create your PixelPin developer account.
Download the Zend Framework 2.x MVC Skeleton Application
Downloading an example website allows you to understand how to install PixelPin Auth into a Zend Framework 2 website. The knowledge you'll learn from installing the module will allow you to install the module onto your own website.
Click on the link to find a guide on how to Download and install the Zend Framework 2.x MVC Skeleton Application.
From your Zend website's root directory, run composer require pixelpinplugins/pixelpin-auth in your favourite CLI. The output should look something like this:
Configuring the plugin
Next you'll need to create a table in your database. Go to vendor/pixelpinplugins/pixelpin-zfc-user/data and open your preferred .sql file and run the query in your DB.
Next you'll need to create another table in your database. Go to vendor/pixelpinplugins/pixelpin-auth/data and open your preferred .sql file and run the query in your DB.
Next go to your config/application.config.php file and add the following modules to the module array:
Next go to vendor/pixelpinplugins/pixelpin-auth/config/exampleautoload folder. This folder shows you what you need in your config/autoload folder. If you want, you can copy everything in this folder over to your config/autoload folder, but if you have these exact files already in your config/autoload just copy the contents of the file into that existing file (e.g. copy the content in global.php.dist to global.php).
Open config/autoload/database.local.php and type your database details into the dbParams array at the top of the page and save the file.
Open config/autoload/global.php.dist and copy the contents of the return array into the return array in config/autoload/global.php and save the file.
Staying in config/autoload/global.php, you'll need to insert your zend framework 2 website's Client ID and Client Secret acquired from PixelPin. You'll need the Redirect URI to create a developer account to get your Client ID and Client Secret. Your Redirect URI will be, for example, http(s)://local.zend.co.uk/pixelpin-auth/hauth?hauth.done=PixelPin. If you haven't created a PixelPin developer account before, a guide can be found here to guide you through the steps to create a PixelPin developer account.
Next go to config/autoload/scn-social-auth.global.php and set 'pixelpin_enabled' to equal true.
Next in your module/application/view/layout/layout.phtml (based on the default layout.phtml) enter the following code in your nav bar:
<?php echo $this->navigation('navigation')->menu()->setUlClass('nav navbar-nav'); ?>
So it'll look something like this:
The module is now installed.
Click here to find out how you can add the PixelPin logo to the SSO button.
Testing the module
Log in/Register page
The following image is an example of a login/register page. Once you click this button it will redirect you to the PixelPin login page, once the user authenticates it will redirect to the 'logged in' page.
Example logged in page
This image is an example of a logged-in page. The code for this page can be found in vendor/pixelpinplugins/pixelpin-zfc-user/view/zfc-user-pixelpin/user/index.phtml. Index.phtml contains the logic to retrieving the user data as well as the code for the logout button.
PixelPin Auth is an open-source project that allows developers using PixelPin to improve the plugin. You can find the links to the modules repo's below: