Send SMS in mobile using nexmo from laravel application

tutspack laravel

Hello Artisans,

How are you doing? In this tutorial, I’ll show you,Send SMS in mobile using nexmo from your laravel application. If you don’t know how to send SMS using nexmo from laravel, don’t worry You are the right place. I will show you everything from scratch step by step. So here we go.

In this example, I will show you a very simple example of sending sms using nexmo/vonage api in the laravel app. You can easily use this code the version of laravel 6,7 and 8.

let’s follow bellow steps:

Nexmo SMS Laravel

Step 1: Install Laravel

In this step, we need to download a fresh laravel project as we will see it from scratch. To install Laravel via Composer run the below command.

composer create-project laravel/laravel laravel_nexmo

Step 2: Create Nexmo Account

Then, You have to create a nexmo account. If already you have an account don’t need to create an account, otherwise create an account from here:

Step 3: Add Your Nexmo Credentials in .env file

Add on env file as like bellow:



Read Also: CRUD Example with Repository Design Pattern in Laravel

Step 4: Install nexmo/client Package via composer

In this step,You have to install nexmo/client package using composer. Run this code in your terminal.

composer require nexmo/client

Step 5: Create Controller

Now time to create a controller, Run this code in your terminal

php artisan make:controller SmsController

Now you have to go SmsController.


use Exception;
use Vonage\SMS\Client;
use Illuminate\Http\Request;

public function index()
        $code = rand(100,500);
        $basic  = new \Vonage\Client\Credentials\Basic("NEXMO_KEY", "NEXMO_SECRET");
        $client = new \Vonage\Client($basic);
        $response = $client->sms()->send(
            new \Vonage\SMS\Message\SMS("SMS_FROM", 'BRAND', "Your verification code is $code")

        $message = $response->current();

        if ($message->getStatus() == 0) {
            echo "The message was sent successfully\n";
        } else {
            echo "The message failed with status: " . $message->getStatus() . "\n";


Then copy this index method and paste inside your controller then customize according to your requirement.

Nexmo SMS Laravel

Step 6: Create Route

Now create a route in web.php file.



use App\Http\Controllers\SmsController;
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    return view('welcome');
Route::get('sendSMS', [SmsController::class, 'index']);

Congratulations. Our all step has done. Now run php artisan serve in your terminal.

 php artisan serve 

Now hit this URL in your browser. Then check your phone. . . . .

nexmo sms laravel
nexmo sms

Nexmo SMS Laravel

Hope It will help You .

Github :

Let’s read another blog

Read More: Laravel 8 API CRUD with Authentication using Sanctum

About Anisur Rahman Shahin

Hello. My name is Shahin. I'm a tech enthusiast guy. Personally, I’m an Optimistic and always in hurry kinda person. I'm a freelance web developer. I am working at Zakir Soft as Laravel Developer. My Portfolio website:

View all posts by Anisur Rahman Shahin →

One Comment on “Send SMS in mobile using nexmo from laravel application”

Leave a Reply

Your email address will not be published.