user image

Joseph Morgan
Published in : 2022-02-09

[solved] Class "App\Exceptions\Client" not found

Laravel

Hello everyone I am facing issues in Laravel while I am using Twillo to send messages I am following this article https://www.twilio.com/blog/create-sms-portal-laravel-php-twilio to create the SMS but when I start using this code 
Class "App\Exceptions\Client" not found

<?php

/**
 * Sends sms to user using Twilio's programmable sms client
 * @param String $message Body of sms
 * @param Number $recipients string or array of phone number of recepient
 */
private function sendMessage($message, $recipients) {
    $account_sid = getenv("TWILIO_SID");
    $auth_token = getenv("TWILIO_AUTH_TOKEN");
    $twilio_number = getenv("TWILIO_NUMBER");
    $client = new Client($account_sid, $auth_token);
    $client->messages->create($recipients, 
            ['from' => $twilio_number, 'body' => $message] );
}

an error came to my face says that Client class was not found,
However in the article of clarification there is no class imported & I cannot find it 
Anyone can help!

Comments

Mohamed Atef Date : 2022-02-09

Best answers

46

Best answers

46

Client class should come from the Twillo SDK package you can use install it using the command below 

composer require twilio/sdk

then you can import it into your controller using 

use Twilio\Rest\Client;

You can follow the documentation on the package from here 

Joseph Morgan Date : 2022-02-09

Thanks it's very helpful, Everything is clear here on https://packagist.org/packages/twilio/sdk

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

[solved] Nginx 413 Request Entity Too Large - Laravel
Publish date: 2022-02-01 | Comments: 2
Method Illuminate\Auth\RequestGuard::attempt does not exist.
Publish date: 2022-02-18 | Comments: 2
Laravel clear cache files manually
Publish date: 2022-03-02 | Comments: 2
I want to make multiple foreign keys in Laravel, can I?
Publish date: 2022-01-27 | Comments: 5
[SOLVED] No application encryption key has been specified.
Publish date: 2021-05-17 | Comments: 2
laravel installation error with composer install
Publish date: 2022-02-23 | Comments: 2