mitake-laravel
, (*1)
This is a simple Laravel service provider for making it easy to access the Mitake PHP SDK in your Laravel and Lumen applications., (*2)
Installation
The Mitake service provider can be installed via Composer., (*3)
composer require minchao/mitake-laravel
To use the Mitake service provider, you must register the provider when bootstrapping your application., (*4)
Laravel
Laravel 5.5 and above
The package will automatically register provider and facade., (*5)
Laravel 5.4 and below
Add Mitake\Laravel\MitakeServiceProvider
to the providers
section of your config/app.php
:, (*6)
'providers' => [
// ...
Mitake\Laravel\MitakeServiceProvider::class,
];
Add Mitake facade to the aliases
section of your config/app.php
:, (*7)
'aliases' => [
// ...
'Mitake' => Mitake\Laravel\Facade\Mitake::class,
];
Or use the facade class directly:, (*8)
use Mitake\Laravel\Facade\Mitake;
Lumen
Register the Mitake\Laravel\MitakeServiceProvider
in your bootstrap/app.php
:, (*9)
$app->register(Mitake\Laravel\MitakeServiceProvider::class);
Copy the mitake.php
config file in to your project:, (*10)
mkdir config
cp vendor/minchao/mitake-laravel/config/mitake.php config/mitake.php
Configuration
Publish the package configuration using Artisan (Lumen doesn't support)., (*11)
php artisan vendor:publish --provider="Mitake\Laravel\MitakeServiceProvider"
Then update config/mitake.php
with your credentials. Alternatively, you can update your .env
file., (*12)
MITAKE_USERNAME=username
MITAKE_PASSWORD=password
Usage
To use the Mitake SDK within your app, you need to retrieve it from the service container:, (*13)
$mitake = app(\Mitake\Client::class);
$message = (new \Mitake\Message\Message())
->setDstaddr('0987654321')
->setSmbody('Hello, Laravel IoC Container');
$result = $mitake->send($message);
Or, you can use the Mitake facade:, (*14)
$message = (new \Mitake\Message\Message())
->setDstaddr('0987654321')
->setSmbody('Hello, Facade');
$result = Mitake::send($message);
License
See the LICENSE file for license rights and limitations (BSD 3-Clause)., (*15)