https://github.com/byjg/php-sms-client
https://github.com/byjg/php-sms-client
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/byjg/php-sms-client
- Owner: byjg
- License: mit
- Created: 2023-05-11T00:59:40.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-29T15:19:17.000Z (11 months ago)
- Last Synced: 2025-04-10T15:04:40.450Z (6 months ago)
- Language: PHP
- Size: 29.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# SMS Client
[](https://github.com/byjg/php-sms-client/actions/workflows/phpunit.yml)
[](http://opensource.byjg.com)
[](https://github.com/byjg/php-sms-client/)
[](https://opensource.byjg.com/opensource/licensing.html)
[](https://github.com/byjg/php-sms-client/releases/)This is a simple client to send SMS using different providers.
## Features
* Low code to send SMS
* Classes totally decoupled
* Easy to implement new providers## Usage
### Using ProviderFactory
```php
// Register the provider and associate with a scheme
ProviderFactory::registerProvider(TwilioMessagingProvider::class);// Create a provider
$provider = ProviderFactory::create(new Uri("twilio://$accountSid:$authToken@default"));// Send a message
$response = $byjg->send("12221234567", (new \ByJG\SmsClient\Message("This is a test message")->withSender("+12223217654"));// Check if the message was sent
if ($response->isSent()) {
echo "Message sent";
} else {
echo "Message not sent";
}
```### Using ProviderFactory to send a message to multiple providers depending on the country
```php
// Register the provider and associate with a scheme
ProviderFactory::registerProvider(TwilioMessagingProvider::class);
ProviderFactory::registerProvider(ByJGSmsProvider::class);// Define the provider according to the country prefix
ProviderFactory::registerServices("twilio://accoundId:authToken@default", ["+1"]);
ProviderFactory::registerServices("byjg://username:password@default", ["+55"]);// Send a message and select the provider according to the country prefix
$response = ProviderFactory::createAndSend("+5521900001234", (new \ByJG\SmsClient\Message("This is a test message")));
var_dump($response);$response = ProviderFactory::createAndSend("+12221234567", (new \ByJG\SmsClient\Message("This is a test message"))->withSender("+12223217654"));
var_dump($response);
```## Providers
The providers are the classes responsible to send the text message.
All providers have the following interface:
```php
byjg/webrequest
byjg/sms-client --> ext-curl
```----
[Open source ByJG](http://opensource.byjg.com)----
[Open source ByJG](http://opensource.byjg.com)