SimpleSoftwareIO / simple-sms

Send and receive SMS messages with Laravel
https://www.simplesoftware.io/docs/simple-sms
MIT License
201 stars 87 forks source link

Ability to add in new drivers at runtime #10

Closed benrowe closed 8 years ago

benrowe commented 9 years ago

It would be nice if there was an easy way to write drivers for additional services and have them loaded in.

At the moment the drivers are hard coded and there's no way to specify a different driver.

z2z commented 9 years ago

+1 I am looking for the same ... Extend the package with custom driver.

(Laravel 4.2)

SimplyCorey commented 9 years ago

How would you guys like to see the syntax for this?

Ellrion commented 9 years ago

Look at #8 with this architect we may extend service like this

<?php 
namespace App\ServiceProviders;

use   SimpleSoftwareIO\SMS\SMSServiceProvider as BaseSMSServiceProvider

class SMSServiceProvider extends BaseSMSServiceProvider
{
    public function registerSender()
    {
        parent::registerSender();
        $this->app['sms.sender']->extend('sendername', function ($app) {
            // some logic for creation driver here
            return new MySenderDriver();
        })
    }
}
SimplyCorey commented 9 years ago

I'll be adding this shortly. Most likely this upcoming weekend.

SimplyCorey commented 8 years ago

Fixed in 2.1.0 with the new driver method.