Skip to content

royalwang/Sms-1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sms Component License Build Status Scrutinizer Code Quality

An SMS component for PHP applications.

Installation

composer.json

{
    "require": {
        "yoqut/sms": "~1.0"
    }
}
php composer.phar install

Usage

// Imports
use Yoqut\Component\Sms\Factory\SmsFactory;
use Yoqut\Component\Sms\Factory\GatewayFactory;
use Yoqut\Component\Sms\Gateway\Matcher;
use Yoqut\Component\Sms\Sender\Sender;

// Create a new SMS
$sms = SmsFactory::create();
$sms->setSender('Sender');
$sms->setRecipient('+5550100');
$sms->setMessage('Message');

// Create a new gateway
// Provide host, port, username, password, service number (optional) and prefix patterns (optional)
$gateway = GatewayFactory::create(
    'localhost',
    2775,
    'username',
    'password',
    '5555',
    array('+555')
);

// Array of gateways
$gateways = array($gateway);

// Create a new gateway matcher
$matcher = new Matcher($gateways);
$matchedGateway = $matcher->match($sms);

// Print the matched gateway
echo '<pre>';
print_r($matchedGateway);
echo '</pre>';

// Send an SMS to the matched gateway
if ($matchedGateway) {
    $sender = new Sender();
    $messageId = $sender->send($sms, $matchedGateway);
    echo $messageId;
}

Tests

vendor/phpspec/phpspec/bin/phpspec run

License

MIT License

Authors

The component was created by Sukhrob Khakimov. See the list of contributors.

About

SMS Component for PHP applications

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages