-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:fd6130/exabytes-sms-bundle
- Loading branch information
Showing
7 changed files
with
124 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,54 @@ | ||
# exabytes-sms-bundle | ||
Send sms using exabytes api | ||
exabytes-sms-bundle | ||
=================== | ||
|
||
Send sms using exabytes malaysia api. For more detail regarding the api, please read [documentation](https://support.exabytes.com.my/en/support/solutions/articles/14000110847-bulk-sms-api-integration). | ||
|
||
Requirement | ||
=========== | ||
* PHP 7.2+ | ||
* Symfony 4.4+ and 5+ | ||
|
||
Installation | ||
============ | ||
|
||
`composer require fd6130/exabytes-sms-bundle` | ||
|
||
> If you are using flex, it will automatic add this bundle to `bundles.php`. | ||
Configuration | ||
============= | ||
|
||
Update your .env to include this two variable: | ||
|
||
``` | ||
# .env | ||
EXABYTES_USERNAME= | ||
EXABYTES_PASSWORD= | ||
``` | ||
|
||
And then create the config file `/config/fd_exabytes.yaml` and put the following content: | ||
|
||
```yaml | ||
fd_exabytes: | ||
username: '%env(EXABYTES_USERNAME)%' | ||
password: '%env(EXABYTES_PASSWORD)%' | ||
``` | ||
Inject `ExabytesInterface` and start sending sms: | ||
|
||
```php | ||
private $exabytes; | ||
public function __construct(ExabytesInterface $exabytes) | ||
{ | ||
$this->exabytes = $exabytes; | ||
} | ||
public function sendSMS() | ||
{ | ||
$this->exabytes->send('mobile number', 'message', ExabytesInterface::ASCII); | ||
//... | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Fd\ExabytesBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\Definition\Builder\TreeBuilder; | ||
use Symfony\Component\Config\Definition\ConfigurationInterface; | ||
|
||
class Configuration implements ConfigurationInterface | ||
{ | ||
public function getConfigTreeBuilder(): TreeBuilder | ||
{ | ||
$treeBuilder = new TreeBuilder('fd_exabytes'); | ||
$rootNode = $treeBuilder->getRootNode(); | ||
|
||
$rootNode | ||
->children() | ||
->scalarNode('username')->isRequired()->cannotBeEmpty()->end() | ||
->scalarNode('password')->isRequired()->cannotBeEmpty()->end() | ||
->end() | ||
; | ||
|
||
return $treeBuilder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Fd\ExabytesBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
|
||
class FdExabytesExtension extends Extension | ||
{ | ||
public function load(array $configs, ContainerBuilder $container): void | ||
{ | ||
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); | ||
$loader->load('services.yaml'); | ||
|
||
$configuration = $this->getConfiguration($configs, $container); | ||
$config = $this->processConfiguration($configuration, $configs); | ||
|
||
$definition = $container->getDefinition('fd.exabytes.exabytes'); | ||
$definition->setArgument(0, $config); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
services: | ||
fd.exabytes.exabytes: | ||
class: Fd\ExabytesBundle\Service\Exabytes | ||
arguments: | ||
$client: "@http_client" | ||
Fd\ExabytesBundle\Service\Exabytes: | ||
arguments: | ||
$client: "@http_client" | ||
Fd\ExabytesBundle\Service\ExabytesInterface: "@fd.exabytes.exabytes" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters