AWS Cognito Verify with PHP

Doing user management the right way is hard work. Allowing users to register themselves, and verifying their identity can be difficult. However, using Amazon Cognito and the Vonage Verify API help make it a bit easier by doing the heavy lifting.

With a few web forms, Vonage SDK, and AWS SDK, you can create a standard user management system allowing a user to register, update their credentials, validate their identity, and login. You’ll use the code from the nexmo-community/verify-aws-cognito-php code repo.

NOTE: For educational purposes, the example code in the repo above was kept simple. I did not use a framework, CSS, or Javascript. However, I recommend using a supported framework, and proper CSS styling for a better application observing the proper separation of concerns.


Vonage API Account

To complete this tutorial, you will need a Vonage API account. If you don’t have one already, you can sign up today and start building with free credit. Once you have an account, you can find your API Key and API Secret at the top of the Vonage API Dashboard.

Setup Instructions

Clone the nexmo-community/verify-aws-cognito-php repo from GitHub, and navigate into the newly created directory to proceed.

Install Dependencies

This example requires the use of Composer to install dependencies and set up the autoloader.

Assuming you have Composer installed globally, run:

AWS Setup

This example uses Amazon Cognito User Pools to hold users. I set up a User Pool as follows:

Update Environment

Rename the provided .env.default file to .env and update the values as needed:

NOTE: All placeholders noted by <> need to be updated. Update the others as needed.

Launch or Deploy

Test the app by running it locally with the PHP built-in webserver with the command:

View the main landing page by going to http://localhost:8080 in a web browser.

IMPORTANT: Though this app functions, it is intended for educational purposes and is not ready for public use as-is.


The app flow is as follows:

Next Steps

If you have any questions or run into troubles, you can reach out to @VonageDev on Twitter or inquire in the Nexmo Community Slack team. Good luck.

Developer content from the team at Vonage, including posts on our Java, Node.js, Python, DotNet, Ruby and Go SDKs

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store