Laravel 5 Twilio Namepace - laravel

I am implementing Twilio in Laravel 5, the tutorial I am using is very good https://www.twilio.com/blog/2014/09/getting-started-with-twilio-and-the-laravel-framework-for-php.html.
Do you know what the namespace is for laravel 5?
I am getting
Class 'Services_Twilio_Twiml' not found
Thanks

If you install the twilio/sdk package via composer you should have access to all the Twilio classes automatically, since laravel uses composer's autoloading.
They are not really namespaced. You would use \Services_Twilio_Twiml.

You can tell composer to load your Twilio folder by adding :
"autoload" : {
"classmap" : [ "your/Twilio/folder" ]
}
to your composer.json

If I understood you clearly you have put your Twilio code in a given file and you are getting this error saying "Class 'Services_Twilio_Twiml' not found".
I am writing here possible reason you are getting this.
/config/services.php- you have not added Twilio details which are
i. sid
ii. token
iii. from
in file in which you have integrated your Twilio code, you have to ensure to write use Twilio;
In your app.php you have to add in providers section Twilio which you are using for example: 'Aloha\Twilio\TwilioServiceProvider'
and aliases section 'Twilio' => 'Aloha\Twilio\Facades\Twilio',.
If you look at this you might find answer.

For Laravel 5 (and older Laravel 4 applications) I suggest using the aloha/twilio package. It provides some code samples in the readme file that should help you get going quickly. One can inject a configured object using the TwilioInterface type hint which has methods to send SMSs MMs and calls.

Related

I search faker-avatar for php 8

I want to use avatar in my faker users seeding and I try to use https://github.com/ottaviano/faker-gravatar
But I got error trying to install it :
[InvalidArgumentException]
Package ottaviano/faker-gravatar has a PHP requirement incompatible with your PHP version, PHP extensions and Composer version:
- ottaviano/faker-gravatar 0.1.2 requires php ^7.1 which does not match your installed version 8.1.0.
Looks like it does not support php 8...
Are there similar pluging supporting php 8 ?
Or maybe I can tune this plugin to work under php 8?
Thanks in advance!
You could create an issue on the repo and request that the maintainer update the package to support PHP 8. Alternatively you could fork the repo and either maintain that fork yourself, or create a pull request once you've updated the package.
With the above in mind though, something to note is that package is using an abandoned faker library. There is a new fork that is recommended for use but does not have a gravatar provider.
You could write your own provider for the newer faker library or alternatively go down the very simple route of just implementing a statement to generate a gravatar yourself.
'https://www.gravatar.com/avatar/' . md5(strtolower(trim($faker->email()))) . '?d=identicon';
The above will look for an existing gravatar for the provided email address and return that if it finds one, otherwise will return a default gravatar image which in my example is a geometric pattern based on the email hash.
Whilst this solution might not be as flexible as the package in your question, if all you're after is a gravatar and don't care whether it's isometric or a robot (see default images in the API docs for changing the default image generated) then something simple like this might be all you need.

Laravel mailChimp package error

I try to use the package https://github.com/BlueBayTravel/Mailchimp as in examples but i got an error:
ErrorException in Mailchimp.php line 64:
Undefined property: BlueBayTravel\Mailchimp\Facades\Mailchimp::$users
when i try to use: Mailchimp::users(), while i can get a connection via Mailchimp::getDefaultConnection(); mean the package is completely red, what u guess the problem with me here ?
I saw that you already opened an issue in the package repo.
If you are using Laravel, and you want to use an existing integration with Mailchimp, I would recommend you to give a try to the spatie/laravel-newsletter package. It's the most complete package I've found for the integration Laravel + Mailchimp, and it uses the drewm/mailchimp-api API wrapper (which IMO, is the best php wrapper for Mailchimp). You can find some examples at Freek's blog or at the README file of the project. And if you do not find what you need, you can go to a lower level using the drewm wrapper: $api = Newsletter::getApi();
If this is not what you are looking for, you can always create your own service in Laravel, adapted to your needs and requierements ;)

Loading composer package into Laravel 5.2

I am trying to add the following package to my Laravel 5.2 project. At the top of my class I have added
use PhpImap\Mailbox as ImapMailbox;
use PhpImap\IncomingMail;
use PhpImap\IncomingMailAttachment;
I then do something like this
$mailbox = new ImapMailbox('{imap.gmail.com:993/imap/ssl}INBOX', 'some#gmail.com', '*********', __DIR__);
At the moment, when I visit the page I get
Class 'PhpImap\Mailbox' not found
I have tried many different ways to load it with the same result. Because this package is not Laravel specific, I don't know if I need to add anything else? Normally when I add Laravel packages I create a provider and alias, do I need to do that here?
Any information appreciated.
Thanks

How do I import Twilio in Laravel?

How do I import the Twilio library in Laravel Controller?
I tried several ways of importing in but it does not work
FatalErrorException in TwilioController.php line 13:
Class 'App\Http\Controllers\Services_Twilio' not found
Have you tried to install via composer? The docs seem pretty straight forward.
composer require twilio/sdk
Then you'd initiate the Twilio class in your app. Like so:
$client = new \Services_Twilio($AccountSid, $AuthToken);
Because Laravel is uses namespaces, you'll need to make sure the class reference is pointed to the correct namespace. By adding the \ before Services_Twilio you are referencing the global namespace. You can also use a use statement at the top of your file to reference the Twilio class, so you don't need the \. Here is a good reference on namespaces

Is there any good sample about facebook-php-sdk3.0+ with CodeIgniter2.0+?

I use CodeIgniter2.0.3 and facebook-php-sdk3.1.1 to develop an application.
When I run the project,is says:
Fatal error: Cannot redeclare class Facebook in ../application/libraries/facebook.php on line 24
The source of line 24 is:
class Facebook extends BaseFacebook
What's the reason?How to deal with it?
Check the name of your controller. If it is called Facebook then that is your problem, you cannot have 2 classes called the same thing at once, unless they are in different namespaces.
I wouldn't suggest using the normal Facebook PHP-SDK when there are a number available over on codeigniter sparks that perform most of the same functions but already setup to work with codeigniter without these conflicts.

Resources