Laravel
Laravel is a free, open-source PHP web framework. Intended for the development of web applications following the model–view–controller architectural pattern and based on Symfony.

Let's Get your Laravel App running with SAWO
🙌

Requirement

Steps:

1 SAWO Configuration
1.1. To use SAWO Login you would need an API key which can be obtained by creating a project in the sawo dashboard.
1.2. Once you create your project, you would need to set your project name and hostname. 1.2.1. For development in a local machine, the hostname should be set to 'localhost'.
If using ''localhost" as hostname is not working for you, try "127.0.0.1"
🤓
1.2.2. For production, the hostname should be set to your domain.
If you are adding your domain do not add 'https://', ''http://', 'www' or even trailing backslash. Example: https://dev.sawolabs.com/ should be kept as dev.sawolabs.com
1.3. Copy the API key from the project and keep it safe and secure.
The best practice to store your API key is to store values in .env so that they are not exposed.
2. Installation
To get started with Sawo, use the Composer package manager to add the package to your project's dependencies:
$ composer require sawolabs/sawo-laravel
3. Configuration
3.1. Before using Sawo, you will need to add credentials for your application. These credentials should be placed in your application's config/sawo.php configuration file.
<?php
return [
/*
|--------------------------------------------------------------------------
| Configure Sawo defaults
|--------------------------------------------------------------------------
|
| Supported Identifier Types: "phone_number_sms", "email",
| or "both_email_phone"
*/
'api_key' => env('SAWO_API_KEY', ''),
'api_secret_key' => env('SAWO_SECRET_KEY', ''),
'identifier_type' => env('SAWO_IDENTIFIER_TYPE', 'email'),
'redirect_url' => env('SAWO_REDIRECT', ''),
];
3.2 Add the following in the .env file
SAWO_API_KEY=<YOUR_SAWO_API_KEY_HERE>
SAWO_SECRET_KEY=<YOUR_SAWO_SECRET_KEY_HERE>
SAWO_IDENTIFIER_TYPE=phone_number_sms
SAWO_REDIRECT=https://yourdomain.com/sawo/callback
4. Add Sawo login form to blade template
Include the following code in your login blade template to show Sawo Auth dialog.
@include('sawo::auth')
Once the SAWO SDK is successfully set up, a login form will be rendered in the provided container as displayed in the picture below:

Congratulations !! The SAWO API is now ready to be used in your Laravel application 🤘.

You can also check out SAWO's
Laravel Sample Code.

It's okay, we get it! You got Stuck!
😞
Feel free to contact us on #ask-for-help on our Discord

Copy link
On this page
Let's Get your Laravel App running with SAWO
Requirement
Steps: