PHP code example of nexmo / laravel

1. Go to this page and download the library: Download nexmo/laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nexmo / laravel example snippets


'providers' => [
    // Other service providers...

    Nexmo\Laravel\NexmoServiceProvider::class,
],

use Nexmo\Laravel\Facade\Nexmo;

'aliases' => [
    ...
    'Nexmo' => Nexmo\Laravel\Facade\Nexmo::class,
],

$app->register(Nexmo\Laravel\NexmoServiceProvider::class);

$router->get('/', function () use ($router) {
    app(Nexmo\Client::class);
});

Nexmo::message()->send([
    'to'   => '14845551244',
    'from' => '16105552344',
    'text' => 'Using the facade to send a message.'
]);

$nexmo = app('Nexmo\Client');

$nexmo->message()->send([
    'to'   => '14845551244',
    'from' => '16105552344',
    'text' => 'Using the instance to send a message.'
]);

Nexmo::calls()->create([
    'to' => [[
        'type' => 'phone',
        'number' => '14155550100'
    ]],
    'from' => [
        'type' => 'phone',
        'number' => '14155550101'
    ],
    'answer_url' => ['https://example.com/webhook/answer'],
    'event_url' => ['https://example.com/webhook/event']
]);
bash
mkdir config
cp vendor/nexmo/laravel/config/nexmo.php config/nexmo.php
bash
php artisan vendor:publish