Comments (2)
Create a manager class that extends SimpleSoftwareIO\SMS\DriverManager
register your sms service on this class, Create a copy of SimpleSoftwareIO\SMS\SMSServiceProvider
and name it MyCustomServiceProvider
on top of this class import these two classes
use MyNamespace\DriverManager;
use SimpleSoftwareIO\SMS\SMS;
Add you custom service to the config file that it can be loaded
Your custom Driver manager
namespace MyNamspace\SMS;
use MyNamespace\SmsSender;
use SimpleSoftwareIO\SMS\DriverManager as Manager;
class DriverManager extends Manager
{
public function createSmssenderDriver()
{
$config = $this->app['config']->get('sms.smssender', []);
$provider = new SmsSender(
$config['api_key'],
$config['username']
);
return $provider;
}
}
Your custom service provider should be something simillar to this
namespace MyNamespace\SMS;
use MyNamespace\DriverManager;
use SimpleSoftwareIO\SMS\SMS;
use Illuminate\Support\ServiceProvider;
class MyCustomServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;
/**
* Bootstrap the application events.
*/
public function boot()
{
$this->mergeConfigFrom( __DIR__.'/config/sms.php' , 'sms.'),;
}
/**
* Register the service provider.
*/
public function register()
{
$this->app->singleton('sms', function ($app) {
$this->registerSender();
$sms = new SMS($app['sms.sender']);
$this->setSMSDependencies($sms, $app);
//Set the from setting
if ($app['config']->has('sms.from')) {
$sms->alwaysFrom($app['config']['sms']['from']);
}
return $sms;
});
}
/**
* Register the correct driver based on the config file.
*/
public function registerSender()
{
$this->app['sms.sender'] = $this->app->share(function ($app) {
return (new DriverManager($app))->driver();
});
}
/**
* Set a few dependencies on the sms instance.
*
* @param SMS $sms
* @param $app
*/
private function setSMSDependencies($sms, $app)
{
$sms->setContainer($app);
$sms->setQueue($app['queue']);
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return array('sms', 'sms.sender');
}
}
thats it your new service will now work with smplle-sms package Custom Package
from simple-sms.
Thanks @weezqyd
With a few modifications this worked very well.
from simple-sms.
Related Issues (20)
- Exception Services_Twilio_RestException when queuing an SMS HOT 4
- Twilio Receive Messages Error HOT 4
- Can´t send sms with Zenvia HOT 7
- Api params should be in config HOT 2
- Lumen support HOT 1
- Critical error -- Laravel 5.4 deprecated "share" method. Use singleton instead. HOT 9
- Dependency [jeremeamia/superclosure] removed in laravel 5.4 HOT 1
- Class sms does not exist error HOT 4
- laravel 5.4 HOT 12
- How to add new carrier without changing EmailSMS.php file? HOT 2
- Can I configure Queue settings when using queue to send SMS?
- Twilio outdated HOT 5
- Dynamic driver HOT 2
- Infobip Driver HOT 1
- Laravel 5.3 error `FatalThrowableError Call to undefined method SimpleSoftwareIO\SMS\SMSServiceProvider::send()` HOT 3
- Having issue HOT 4
- Interest? HOT 6
- laravel 8 support
- sms HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simple-sms.