Skip to content

Commit

Permalink
feat(namespace): change in namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
sudkumar committed Oct 20, 2019
1 parent f60f9d4 commit 1b73745
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 123 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# Laravel service provider for MSG91
# Laravel service provider for Msg91

_This library requires a minimum PHP version of 7.1_

This is a **[laravel](https://laravel.com) service provider** for [MSG91 APIs](https://docs.msg91.com/collection/msg91-api-integration/5/pages/139). It wraps the [msg91-php][client] client and provides the same functionality for Laravel applications by exposing a Service Provider and Facade.
This is a **[laravel](https://laravel.com) service provider** for [Msg91 APIs](https://docs.msg91.com/collection/msg91-api-integration/5/pages/139). It wraps the [msg91-php][client] client and provides the same functionality for Laravel applications by exposing a Service Provider and Facade.

> **NOTE**: The project is under active development and so, some apis are subjected to change before of `v1.0.0` release.
## Table of Contents

- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Examples](#examples)
- [Create a Client](#create-a-client)
- [Managing OTPs](#managing-otps)
- [Send OTP](#send-otp)
- [Verify OTP](#verify-otp)
- [Resend OTP](#resend-otp)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Examples](#examples)
- [Create a Client](#create-a-client)
- [Managing OTPs](#managing-otps)
- [Send OTP](#send-otp)
- [Verify OTP](#verify-otp)
- [Resend OTP](#resend-otp)

## Installation

Expand All @@ -28,31 +28,31 @@ composer require craftsys/msg91-laravel

### Laravel 5.5+

If you're using Laravel 5.5 or above, the package will automatically register the `Craftsys\MSG91Client\Laravel\MSG91ServiceProvider` provider and aliases `Craftsys\MSG91Client\Laravel\Facade` facade to `MSG91`.
If you're using Laravel 5.5 or above, the package will automatically register the `Craftsys\Msg91\Msg91LaravelServiceProvider` provider and aliases `Craftsys\Msg91\Facade\Msg91` facade to `Msg91`.

### Laravel 5.4 and below

Add `Craftsys\MSG91Client\Laravel\MSG91ServiceProvider` to the `providers` array in your `config/app.php`:
Add `Craftsys\Msg91\Msg91LaravelServiceProvider` to the `providers` array in your `config/app.php`:

```php
'providers' => [
// Other service providers...
Craftsys\MSG91Client\Laravel\MSG91ServiceProvider::class,
Craftsys\Msg91\Msg91LaravelServiceProvider::class,
],
```

If you want to use the facade interface, you can `use` the facade class when needed:

```php
use Craftsys\MSG91Client\Laravel\Facade;
use Craftsys\Msg91\Facade\Msg91;
```

Or add an alias in your `config/app.php`

```php
'aliases' => [
// other aliases here
'MSG91' => Craftsys\MSG91Client\Laravel\Facade::class,
'Msg91' => Craftsys\Msg91\Facade\Msg91::class,
],
```

Expand All @@ -61,7 +61,7 @@ in an example route or in `php artisan tinker` if you are in Laravel.

```php
// this should print an array of some default configuration values
MSG91::otp()->toArray()
Msg91::otp()->toArray()
```

If there is an issue, please check the steps again or open an issue for support.
Expand All @@ -78,21 +78,21 @@ The package can be configured by providing a `msg91` key inside your `config/ser
return [
// along with other services
"msg91": [
'key' => env("MSG91_KEY"),
'key' => env("Msg91_KEY"),
],
];
```

and update the `.env` file to get the desired values e.g. `MSG91_KEY`.
and update the `.env` file to get the desired values e.g. `Msg91_KEY`.

Please visit [msg91-php configuration][client-configuration] for a detailed description about the available options and their default values.

## Usage

Once you have [Configured](#configuration) the Laravel/Lumen application to use the service provider and have aliased the facade to `MSG91`, you will have to [msg91-php][client] client `Craftsys\MSG91\Client`'s instance.
Once you have [Configured](#configuration) the Laravel/Lumen application to use the service provider and have aliased the facade to `Msg91`, you will have to [msg91-php][client] client `Craftsys\Msg91\Client`'s instance.

```php
MSG91::otp()
Msg91::otp()
->to(919999999999)
->send()
```
Expand All @@ -118,15 +118,15 @@ MGS91::otp()
### Verify OTP

```php
MSG91::otp(1234) // OTP to be verified
Msg91::otp(1234) // OTP to be verified
->to(912343434312) // phone number with country code
->verify(); // Verify
```

### Resend OTP

```php
MSG91::otp()
Msg91::otp()
->to(912343434312) // set the mobile with country code
->via("text") // way of retry
->resend(); // resend otp
Expand Down
126 changes: 63 additions & 63 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
{
"name": "craftsys/msg91-laravel",
"description": "Laravel service provider for MSG91 apis.",
"license": "MIT",
"type": "library",
"authors": [
{
"name": "Sudhir Mitharwal",
"email": "[email protected]",
"role": "Developer",
"homepage": "http://github.com/sudkumar"
}
],
"keywords": [
"msg91",
"php",
"laravel",
"otp"
],
"homepage": "https://github.com/craftsys/msg91-laravel",
"support": {
"issues": "https://github.com/craftsys/msg91-laravel/issues",
"source": "https://github.com/craftsys/msg91-laravel",
"email": "[email protected]"
},
"require": {
"php": ">=7.1",
"craftsys/msg91-php": "^0.4.2",
"illuminate/support": "^5.2|^6.0"
},
"require-dev": {
"orchestra/testbench": "^4.2",
"phpunit/phpunit": "^8.4"
},
"extra": {
"branch-alias": {
"dev-master": "0.x.x-dev"
"name": "craftsys/msg91-laravel",
"description": "Laravel service provider for Msg91 apis.",
"license": "MIT",
"type": "library",
"authors": [
{
"name": "Sudhir Mitharwal",
"email": "[email protected]",
"role": "Developer",
"homepage": "http://github.com/sudkumar"
}
],
"keywords": [
"msg91",
"php",
"laravel",
"otp"
],
"homepage": "https://github.com/craftsys/msg91-laravel",
"support": {
"issues": "https://github.com/craftsys/msg91-laravel/issues",
"source": "https://github.com/craftsys/msg91-laravel",
"email": "[email protected]"
},
"laravel": {
"aliases": {
"MSG91": "Craftsys\\MSG91Client\\Laravel\\Facade"
},
"providers": [
"Craftsys\\MSG91Client\\Laravel\\MSGServiceProvider"
]
}
},
"config": {
"optimize-autoloader": true,
"sort-packages": true
},
"prefer-stable": true,
"minimum-stability": "dev",
"autoload": {
"psr-4": {
"Craftsys\\MSG91Client\\Laravel\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Craftsys\\MSG91Client\\Laravel\\Test\\": "tests/"
"require": {
"php": ">=7.1",
"craftsys/msg91-php": "^0.5",
"illuminate/support": "^5.2|^6.0"
},
"require-dev": {
"orchestra/testbench": "^4.2",
"phpunit/phpunit": "^8.4"
},
"config": {
"optimize-autoloader": true,
"sort-packages": true
},
"prefer-stable": true,
"minimum-stability": "dev",
"autoload": {
"psr-4": {
"Craftsys\\Msg91\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Craftsys\\Tests\\Msg91\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "0.x.x-dev"
},
"laravel": {
"aliases": {
"Msg91": "Craftsys\\Msg91\\Facade\\Msg91"
},
"providers": [
"Craftsys\\Msg91\\Msg91LaravelServiceProvider"
]
}
},
"scripts": {
"test": "phpunit --colors=always"
}
},
"scripts": {
"test": "phpunit --colors=always"
}
}
26 changes: 0 additions & 26 deletions src/Facade.php

This file was deleted.

26 changes: 26 additions & 0 deletions src/Facade/Msg91.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Craftsys\Msg91\Facade;

use Craftsys\Msg91\Client;
use Illuminate\Support\Facades\Facade;

/**
* Facade for Craftsys\Msg91\Client
*
* @method static \Craftsys\Msg91\OTPMessage otp(int|null $otp = null)
*/
class Msg91 extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*
* @throws \RuntimeException
*/
protected static function getFacadeAccessor()
{
return Client::class;
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Craftsys\MSG91Client\Laravel;
namespace Craftsys\Msg91;

use Craftsys\MSG91Client\Client;
use Craftsys\Msg91\Client;
use Illuminate\Support\ServiceProvider;

class MSGServiceProvider extends ServiceProvider
class Msg91LaravelServiceProvider extends ServiceProvider
{
/**
* Register the application services.
Expand All @@ -14,7 +14,7 @@ class MSGServiceProvider extends ServiceProvider
*/
public function register()
{
// Bind MSG91 Client in Service Container.
// Bind Msg91 Client in Service Container.
$this->app->singleton(Client::class, function ($app) {
$config = $app['config'];
return new Client($config->get('services.msg91'));
Expand Down
4 changes: 2 additions & 2 deletions tests/ServiceProviderTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Craftsys\MSG91Client\Laravel\Test;
namespace Craftsys\Tests\Msg91;

use Craftsys\MSG91Client\Client;
use Craftsys\Msg91\Client;

class ServiceProviderTest extends TestCase
{
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Craftsys\MSG91Client\Laravel\Test;
namespace Craftsys\Tests\Msg91;

use Orchestra\Testbench\TestCase as BaseTestCase;
use Craftsys\MSG91Client\Laravel\MSGServiceProvider;
use Craftsys\MSG91Client\Laravel\Facade;
use Craftsys\Msg91\Msg91LaravelServiceProvider as ServiceProvider;
use Craftsys\Msg91\Facade\Msg91 as Facade;

abstract class TestCase extends BaseTestCase
{
Expand All @@ -18,7 +18,7 @@ abstract class TestCase extends BaseTestCase
protected function getPackageProviders($app)
{
return [
MSGServiceProvider::class,
ServiceProvider::class,
];
}

Expand All @@ -32,7 +32,7 @@ protected function getPackageProviders($app)
protected function getPackageAliases($app)
{
return [
'MSG91' => Facade::class
'Msg91' => Facade::class
];
}
}

0 comments on commit 1b73745

Please sign in to comment.