user

Joseph Morgan

9 Feb 2022

[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 //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

9 Feb 2022

Best Answer

best answer
githubgithubgithub

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 

Replies

Joseph Morgan

9 Feb 2022

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

© 2024 Copyrights reserved for web-brackets.com